← Back to archive

Stdle #154 · ownership · 2026-11-07

What does this Rust snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

fn first_word(s: &String) -> &str {
&s[0..3]
}
fn main() {
let s = String::from("hello world");
let w = first_word(&s);
println!("{} {}", w, s);
}
Ownership
4 attempts left

Answer & explanation