Closed
Description
The Rust book on Guessing Game - Processing a Guess says that after compiling the example we'll get a warning. However, I didn't get one:
~/projects/rust $ cargo new guessing_game_2 --bin
Created binary (application) `guessing_game_2` project
~/projects/rust $ cd guessing_game_2/
~/projects/rust/guessing_game_2 $ cargo build
Compiling guessing_game_2 v0.1.0 (file:///home/vag/projects/rust/guessing_game_2)
Finished debug [unoptimized + debuginfo] target(s) in 0.52 secs
~/projects/rust/guessing_game_2 $ cargo run
Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target/debug/guessing_game_2`
Hello, world!
~/projects/rust/guessing_game_2 $ cat > src/main.rs
use std::io;
fn main() {
println!("Guess the number!");
println!("Please input your guess.");
let mut guess = String::new();
io::stdin().read_line(&mut guess)
.expect("Failed to read line");
println!("You guessed: {}", guess);
}
~/projects/rust/guessing_game_2 $ cargo build
Compiling guessing_game_2 v0.1.0 (file:///home/vag/projects/rust/guessing_game_2)
Finished debug [unoptimized + debuginfo] target(s) in 0.65 secs
According to the book I expected:
src/main.rs:10:5: 10:39 warning: unused result which must be used,
#[warn(unused_must_use)] on by default
src/main.rs:10 io::stdin().read_line(&mut guess);
I installed rust via https://rustup.rs/ and I got
$ rustc --version && cargo --version
rustc 1.12.0 (3191fbae9 2016-09-23)
cargo 0.13.0-nightly (109cb7c 2016-08-19)
I am on
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
Metadata
Metadata
Assignees
Labels
No labels