Limited time left to renew for 2026! Renew & get unlimited access to LU|HSWs for only $80. Renew today >
Ultimate Rust - Crash Course 2021
Example: reading a file
cargo new hello_rust cd hello_rust cargo run Inside src/main.rs :
pub trait Summary fn summarize(&self) -> String; ultimate rust crash course
fn main() println!("Hello, Rust!");
fn main() let x = 5; // immutable // x = 6; // ERROR: cannot assign twice to immutable variable let mut y = 10; // mutable y = 11; // OK Example: reading a file cargo new hello_rust cd
Congratulations. You now speak enough Rust to be dangerous. Go write some safe, fast code. 🦀
let mut s = String::from("hello"); change(&mut s); fn main() println!("Hello
let x = 5; let y = x; // copy, both valid let s1 = String::from("hello"); let s2 = s1.clone(); // expensive, explicit 9. Borrowing & References (Without Taking Ownership) Instead of moving, you can borrow a reference.