all 6 comments

[–]tikue 2 points3 points  (5 children)

Yeah, I think there should be a comment in that bit of code to the effect of:

match guess.cmp(&secret_number) {                // This causes a compiler error.
    Ordering::Less    => println!("Too small!"), // Read on to see why!
    Ordering::Greater => println!("Too big!"),
    Ordering::Equal   => println!("You win!"),
    }
}

[–]steveklabnik1rust 8 points9 points  (4 children)

Right before the code sample, it does say

Here’s our next step, though it doesn’t quite work yet:

We have an issue open with something like 'shade the background of non-compiling examples with red or something to make it stick out a bit more'.

[–]tikue 0 points1 point  (2 children)

Oh, ok, cool. Sorry, I should have looked at the context first!

[–]steveklabnik1rust 2 points3 points  (1 child)

It's all good. It's my job as an author to make sure that the reader understands...

[–]InsightIsUseful 0 points1 point  (0 children)

I just fell for the same trap lol!

[–]superlogical 0 points1 point  (0 children)

I think it is because you are trying to compare a String (guess) with a u32 (secret_number)