diff --git a/guessing_game/Cargo.lock b/guessing_game/Cargo.lock new file mode 100644 index 0000000..ee5d790 --- /dev/null +++ b/guessing_game/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "guessing_game" +version = "0.1.0" diff --git a/guessing_game/Cargo.toml b/guessing_game/Cargo.toml new file mode 100644 index 0000000..4e348c8 --- /dev/null +++ b/guessing_game/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "guessing_game" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/guessing_game/src/main.rs b/guessing_game/src/main.rs new file mode 100644 index 0000000..14ff42b --- /dev/null +++ b/guessing_game/src/main.rs @@ -0,0 +1,23 @@ +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 +} diff --git a/hello_cargo/Cargo.lock b/hello_cargo/Cargo.lock new file mode 100644 index 0000000..dd1d0bb --- /dev/null +++ b/hello_cargo/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "hello_cargo" +version = "0.1.0" diff --git a/hello_cargo/Cargo.toml b/hello_cargo/Cargo.toml new file mode 100644 index 0000000..0f4a343 --- /dev/null +++ b/hello_cargo/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "hello_cargo" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/hello_cargo/src/main.rs b/hello_cargo/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/hello_cargo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/hello_world/main b/hello_world/main new file mode 100755 index 0000000..713420a Binary files /dev/null and b/hello_world/main differ diff --git a/hello_world/main.rs b/hello_world/main.rs new file mode 100644 index 0000000..891ede1 --- /dev/null +++ b/hello_world/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, World!") +}