Hands-on Rust: Beta 2 - Trimming Input (page 25)

Hi, on page 25 in the Trimming Input section, after this text:

“You can see this by replacing your last println! call with the following:”

println!("{:?}", name);

I believe needs to be fixed to use the function like so:

println!("{:?}", what_is_your_name());

1 Like

I see how this errata happened now, the book has the main function on p. 24 as:

fn main() {
println!("Hello, what's your name?");
println!("Hello, {}", what_is_your_name())
}

But the online code example throws the function output into a variable:

fn main() {
    println!("Hello, what's your name?");
    let name = what_is_your_name();
    println!("{:?}", name);
}
1 Like

Thank you! I’ve put this into the book’s issue tracker, it’ll be resolved for the next beta. Keeping the backing code (which auto-builds before each time I commit changes) synced with the book (which doesn’t) can be tricky sometimes. Thanks again - I’ll get that resolved.

2 Likes