Color theme
0 day streak0 XPP1
RustQuiz mode
MISSION 1 OF 3

Grow a plant label

0 XP earned
Rust track: MasterMission: BeginnerMutable bindingsOwned stringsString appending
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 / 6 challenges
KNOWLEDGE CHECK

Predict the result.

Which finished plant label is printed?

main.rs
fn main() {    let mut label = String::from("fern");    label.push_str("-shade");    println!("{}", label);}

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.

Review the lesson

A nursery label begins with a plant name and gains a care instruction. String owns growable text, unlike a borrowed string literal. Rust bindings are immutable by default, so mut allows this label to change. push_str appends a string slice to the existing String without replacing its earlier characters.

Choose your answer+25 XP on first completion