A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-100.rs
1fnmain(){
2lets=String::from("rust");
3lett=s;
4println!("{}",t.len());
5println!("{}",t);
6}
Ownership
Answer & explanation
Console output
4
rust
Why
Assigning a String to a new binding moves ownership rather than copying the heap buffer. The original s becomes invalid, but t now owns the same "rust" data, so t.len() is 4 and printing t yields "rust". Printing the new owner is always valid after a move.