From c56962282e2a62d3983186086ad6eea104f065ad Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Mon, 25 Mar 2024 01:27:43 +0100 Subject: [PATCH] Bookmark - ch2 --- 02-guessing_game/Cargo.toml | 8 ++++++++ 02-guessing_game/src/main.rs | 15 +++++++++++++++ README.md | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 02-guessing_game/Cargo.toml create mode 100644 02-guessing_game/src/main.rs 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