Where to suggest changes to the tutorial

Complete newbie here, working my way through the official tutorial on my Ubuntu laptop:

https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html

This code does not work for me because the input string ends with a newline:

io::stdin()
.read_line(&mut guess)
.expect("Failed to read line");

println!("You guessed: '{}'", guess);

You guessed: '42
'

So to make it work I needed to

guess = guess.replace("\n", "");

Is this the right channel to communicate this?

If you notice the next line:

let guess: u32 = match guess.trim().parse() {
            Ok(num) => num,
            Err(_) => continue,
        };

there is a trim call - that removes the \n.

3 Likes

oops my bad, a cut-and-paste error. Sorry about that.

All good. Please keep sharing your oops. Out here, some of us still learn from others questions and mistakes.

3 Likes

There is another suggestion: in the middle of chapter 9.2, should we refer to chapter 10.2 after the following lines " This error points out that we’re only allowed to use the ? operator in a function that returns Result, Option, or another type that implements FromResidual",

Because apparently traits implementation is discussed later, in chapter 10.2, unless I missed earlier mentions of it. So presumably at this point in the book a first time reader might not know about it. WDYT?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.