A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-136.rs
1fnshow(s:&str)->usize{s.len()}
2fnmain(){
3letowned=String::from("hello");
4println!("{}",show(&owned));
5}
Strings
Answer & explanation
Console output
5
Why
Functions almost always take `&str` rather than `&String` because `&String` coerces to `&str` automatically (deref coercion), while the reverse is not true. So `show(&owned)` works even though `owned` is a `String`. `"hello"` is five ASCII bytes, so `.len()` returns 5.