Issue with tutorial guessing game


I’m working through the tutorial and on this line:

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

I’m getting the following error:

error: this function takes 0 parameters but 1 parameter was supplied [E0061]

it’s occurring because I take it that read_line is not supposed to be passed parameters. So when I change it to this:

let input = io::stdin().read_line()
        .expect("Failed to read line");

And print the result of input everything works fine. Has there been a change in rust? or is there something I’m missing. Also, if I remove &mut guess and comment out the let for guess the program compiles and runs perfectly.

Just trying to get a handle on this. Thanks!


The code in the tutorial works for me in the current stable version of Rust. What version of Rust are you using?


OS X – homebrew version 1.3.0 stable was well. Do you think I should uninstall that and use the installer method?


The code in the tutorial should definitely work in Rust 1.3. Here’s the read_line documentation for 1.3.0.

read_line took zero arguments back in old pre-1.0 versions of Rust. Is it possible you have more than one version installed? What does rustc --version print?


rustc 0.13.0-nightly (5ba610265 2014-12-25 18:01:36 +0000)

is what the version reads. So I think I have an old version that homebrew is using.


yup that is what it was. The Homebrew version # states that rust is 1.3 but rustic isn’t. I removed it and downloaded from the website and now rustc gives me this:

rustc 1.3.0 (9a92aaf19 2015-09-15)