diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-02-19 19:25:11 +0100 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-02-19 19:25:11 +0100 |
commit | 97a3274a775d0fbd8f5fb3ad16c3381caab83251 (patch) | |
tree | c2fc6cc5cd9233053d5f0da35afdda88bff82a31 |
init
-rw-r--r-- | .gitignore | 9 | ||||
-rw-r--r-- | guessing_game/.gitignore | 1 | ||||
-rw-r--r-- | guessing_game/Cargo.lock | 140 | ||||
-rw-r--r-- | guessing_game/Cargo.toml | 7 | ||||
-rw-r--r-- | guessing_game/src/main.rs | 35 | ||||
-rwxr-xr-x | hello-world/main | bin | 0 -> 471760 bytes | |||
-rw-r--r-- | hello-world/main.rs | 3 | ||||
-rw-r--r-- | hello_cargo/.gitignore | 1 | ||||
-rw-r--r-- | hello_cargo/Cargo.lock | 7 | ||||
-rw-r--r-- | hello_cargo/Cargo.toml | 6 | ||||
-rw-r--r-- | hello_cargo/src/main.rs | 3 |
11 files changed, 212 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4d058db --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml diff --git a/guessing_game/.gitignore b/guessing_game/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/guessing_game/.gitignore @@ -0,0 +1 @@ +/target diff --git a/guessing_game/Cargo.lock b/guessing_game/Cargo.lock new file mode 100644 index 0000000..e60d026 --- /dev/null +++ b/guessing_game/Cargo.lock @@ -0,0 +1,140 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "guessing_game" +version = "0.1.0" +dependencies = [ + "rand", +] + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "syn" +version = "2.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/guessing_game/Cargo.toml b/guessing_game/Cargo.toml new file mode 100644 index 0000000..d508e95 --- /dev/null +++ b/guessing_game/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "guessing_game" +version = "0.1.0" +edition = "2021" + +[dependencies] +rand = "0.8.5" diff --git a/guessing_game/src/main.rs b/guessing_game/src/main.rs new file mode 100644 index 0000000..fccd212 --- /dev/null +++ b/guessing_game/src/main.rs @@ -0,0 +1,35 @@ +use rand::Rng; +use std::cmp::Ordering; +use std::io; + +fn main() { + println!("Guess the number!"); + + let secret_number = rand::thread_rng().gen_range(1..=100); + + loop { + println!("Please input your guess."); + + let mut guess = String::new(); + + io::stdin() + .read_line(&mut guess) + .expect("Failed to read line"); + + let guess: u32 = match guess.trim().parse() { + Ok(num) => num, + Err(_) => continue, + }; + + println!("You guessed: {}", guess); + + match guess.cmp(&secret_number) { + Ordering::Less => println!("Too small!"), + Ordering::Greater => println!("Too big!"), + Ordering::Equal => { + println!("YOU WIN!"); + break; + } + } + } +} diff --git a/hello-world/main b/hello-world/main Binary files differnew file mode 100755 index 0000000..ac54042 --- /dev/null +++ b/hello-world/main diff --git a/hello-world/main.rs b/hello-world/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/hello-world/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/hello_cargo/.gitignore b/hello_cargo/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/hello_cargo/.gitignore @@ -0,0 +1 @@ +/target 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!"); +} |