Rust
Beginner
1 min read
Installing Rust and Using Rustup
Example
# Install rustup and the stable toolchain (run in your terminal)
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Verify installation
# $ rustc --version
# rustc 1.78.0 (9b00956e5 2024-04-29)
# $ cargo --version
# cargo 1.78.0 (54d8815d0 2024-03-26)
# Update to the latest stable release
# $ rustup update
# Show installed toolchains
# $ rustup show
# Add a cross-compilation target (e.g. WebAssembly)
# $ rustup target add wasm32-unknown-unknown
# Add the nightly toolchain for experimental features
# $ rustup toolchain install nightly
# Compile a single file with rustc
# $ rustc main.rs -o hello && ./hello
// main.rs compiled above
fn main() {
println!("Installed and running!");
// rustc is the low-level compiler; for real projects use cargo
let info = format!(
"Arch: {} OS: {}",
std::env::consts::ARCH,
std::env::consts::OS
);
println!("{info}");
}