Rust Get Started
Get Started With Rust
At W3Schools, you can try Rust without installing anything.
Our Online Rust Editor runs directly in your browser, and shows both the code and the result:
Install Rust
However, if you want to download and install rust, you can go to rust-lang.org and follow the instructions there.
Or, if you are using the terminal, you can run:
Check Installation
After installing, check if Rust is installed correctly by running:
The output will look something like this, depending on your version number:
Create a New Project
Use Cargo to create a new Rust project:
The output will look something like this:
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
This creates a folder called my_project with the following files:
Cargo.toml: Project settingssrc/main.rs: Main Rust file
The main.rs file contains this default code:
println!("Hello, world!");
}
Build and Run the Project
Next, write the following code to go into the project folder:
Then build and run the project:
The output should be:
Hello, world!
Congratulations! You have just run your first Rust program.