Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

How to Install rust on alpine?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Rust is a multi-paradigm, general-purpose programming language designed for safety and performance, especially safe concurrency. It is notable for enforcing memory safety. It is syntactically similar to C++ and is considered a systems programming language with the mechanisms for low-level memory management, but it also offers high-level features such as functional programming. Alpine Linux is an independent, non-commercial, general-purpose Linux distribution designed for power users who appreciate security, simplicity, and resource efficiency.

Features of Rust

  • Performance: Rust aims to be as efficient and portable as idiomatic C++ without sacrificing safety.
  • Memory Safety: It is designed to be memory safe.
  • Memory Management: It doesn’t use automated garbage collection and provides deterministic management of resources with very low overhead.

Installing rust on alpine

Follow the below steps in order to install rust:

Step 1: Install CURL and GCC.

sudo apk add curl

Installing-curl

Installing curl

sudo apk add gcc

Installing-gcc

Installing GCC

Step 2: Install rust.

curl –proto ‘=https’ –tlsv1.2 -sSf https://sh.rustup.rs | sh

Installing-rust

 

Installing required packages,

Installing-required-packages

Installing Rust

Step 3: Configuring the PATH environment variable,

source $HOME/.cargo/env

Configuring-path-environment

 

Step 4: Verify the installation.

Verifying-installation

 

As shown, we’ve successfully installed rust.

Example: Let’s see a simple program using rust language.

  • Create a file greet.rs

Rust




fn main() {
    println!("Welcome to GeeksforGeeks!");
    println!();
    println!("Thanks for visiting GFG!");
}


  • Compile and execute it,

rustc greet.rs

./greet

Compiled-and-executed-program

 

As you can see, we’ve successfully compiled and executed the program.

My Personal Notes arrow_drop_up
Last Updated : 02 Jun, 2022
Like Article
Save Article
Similar Reads