Color theme
0 day streak0 XPP1
RustLearn mode
MISSION 1 OF 1

Duplicate a rover call sign

0 XP earned
Rust track: MasterMission: AdvancedOwnershipCloningIndependent mutation
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.

x
0 / 2 challenges
LEARN THE CONCEPT

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.

main.rs
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.