diff --git a/02-guessing_game/Cargo.toml b/02-guessing_game/Cargo.toml new file mode 100644 index 0000000..78c94fe --- /dev/null +++ b/02-guessing_game/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "guessing_game" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/02-guessing_game/src/main.rs b/02-guessing_game/src/main.rs new file mode 100644 index 0000000..b35ed0f --- /dev/null +++ b/02-guessing_game/src/main.rs @@ -0,0 +1,15 @@ +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}"); +} diff --git a/README.md b/README.md index 0143b92..2f0ad39 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Me learning Rust. -[Interactive Book](https://rust-book.cs.brown.edu/) \ No newline at end of file +[Interactive Book(mark)](https://rust-book.cs.brown.edu/ch02-00-guessing-game-tutorial.html) \ No newline at end of file