Duplicate a rover call sign
Before you start this master track
Typed functions and collections. Be ready for ownership, moves, mutability, and enum matching.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Understand it, then try it.
A rover needs a backup call sign while retaining its original one. Assigning an owned String directly to another binding normally moves ownership. clone creates a separate owned copy instead. The backup can then grow independently, and the original remains valid for the final status line.
fn main() { let original = String::from("Rover"); let mut backup = original.clone(); backup.push_str("-B"); println!("{} / {}", original, backup);}Each mission is a complete independent Rust program using the standard library. Save as main.rs, compile with rustc main.rs, then run the resulting executable. Rust 2021 edition or later is suitable.
Track the values line by line. Predict the result before running this example in your own editor.