Thursday, February 2, 2017

Rust Programming Language

Rust is a Well Planned Modern Language Comparable to C++ Developed Largely by Mozilla

System Update

To make sure that all of Rust's dependencies are up-to-date, run the following commands.
apt-get update
apt-get dist-upgrade -y
apt-get install curl

Install Rust

Installing Rust is a simple process. Run the following command to launch their installation script.
curl -sSf https://static.rust-lang.org/rustup.sh | sh
When the script finishes, Rust will be installed.

Verifying Rust

To verify that Rust was successfully installed, run rustc -V. You will see output similar to:
rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)

Using Rust

To use Rust, create a file called main.rs and populate it with the following lines of code:
fn main() {
    println!("You have successfully installed rust!");
}
Now run rustc main.rs. You will see an executable file called main in the same directory. Execute it by running ./main. The text "You have successfully installed Rust!" will appear on your screen

[The above installation instructions were taken from here.]

Create a New Project with Cargo

cargo new <project name>


There should be a new project folder with an src folder in it
Create a main.rs file in the src folder
Write code in the main.rs file
To run the project, navigate to the project folder (not inside the src folder)
enter:

cargo run

  Compile and Build Executable

rustc main.rs

No comments:

Post a Comment