24 lines
607 B
Rust
24 lines
607 B
Rust
use std::io;
|
|
|
|
fn main() {
|
|
println!("Guess the number!");
|
|
|
|
println!("Please input your guess: ");
|
|
|
|
// ::new() is an associated type. Function is implemented on this type
|
|
// Returns a new instance of String
|
|
let mut guess = String::new();
|
|
|
|
let apples = 5; // immutable
|
|
let mut bananas = 7; // mutable
|
|
|
|
io::stdin()
|
|
.read_line(&mut guess)
|
|
.expect("Failed to read line!");
|
|
|
|
println!("You guessed: {}", guess);
|
|
|
|
// Ended at start of Recieving user input in ch2
|
|
// https://rust-book.cs.brown.edu/ch02-00-guessing-game-tutorial.html#receiving-user-input
|
|
}
|