Skip to content

Instantly share code, notes, and snippets.

View MicroDevX's full-sized avatar
🎯
Focusing

Hisham MicroDevX

🎯
Focusing
View GitHub Profile
@MicroDevX
MicroDevX / rust_ownership_demo.rs
Created January 2, 2026 21:53
Hello, Memory Safety
fn main() {
let s1 = String::from("hello");
let s2 = s1; // s1 is "moved" to s2 here
// println!("{}", s1);
// ^ Un-commenting the line above would cause a compile error!
// This prevents "double-free" memory bugs.
println!("{}", s2); // This works perfectly.
}