From cd1dfd92fdcd1d751eb6d6b2a551078bbde5dd74 Mon Sep 17 00:00:00 2001 From: AnthonyMichaelTDM <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Sun, 27 Feb 2022 20:07:18 -0800 Subject: [PATCH 1/3] readme's added --- 02_Amazing/rust/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 02_Amazing/rust/README.md diff --git a/02_Amazing/rust/README.md b/02_Amazing/rust/README.md new file mode 100644 index 00000000..f84e546c --- /dev/null +++ b/02_Amazing/rust/README.md @@ -0,0 +1,3 @@ +Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html) + +Conversion to [Rust](https://www.rust-lang.org/) by Anthony Rubick [AnthonyMichaelTDM](https://github.com/AnthonyMichaelTDM) \ No newline at end of file From 020fb6271fee2d22e4beff516c941367b27eac3c Mon Sep 17 00:00:00 2001 From: AnthonyMichaelTDM <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Sun, 27 Feb 2022 20:37:43 -0800 Subject: [PATCH 2/3] bug fix didn't have a minimum accepted input size, and panicked during testing --- 02_Amazing/rust/src/main.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/02_Amazing/rust/src/main.rs b/02_Amazing/rust/src/main.rs index bc85189f..a1471a6a 100644 --- a/02_Amazing/rust/src/main.rs +++ b/02_Amazing/rust/src/main.rs @@ -163,12 +163,6 @@ fn main() { } println!("."); } - - - - - - } fn get_user_input(prompt: &str) -> usize { @@ -187,7 +181,15 @@ fn get_user_input(prompt: &str) -> usize { //from input, try to read a number match raw_input.trim().parse::() { - Ok(i) => break i, // this escapes the loop, returning i + Ok(i) => { + if i>1 { //min size 1 + break i; // this escapes the loop, returning i + } + else { + println!("INPUT OUT OF RANGE. TRY AGAIN."); + continue;// run the loop again + } + } Err(e) => { println!("MEANINGLESS DIMENSION. TRY AGAIN. {}", e.to_string().to_uppercase()); continue; // run the loop again From 099a5be209952755f5d43a25c458884893b7f995 Mon Sep 17 00:00:00 2001 From: AnthonyMichaelTDM <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Sun, 27 Feb 2022 20:49:25 -0800 Subject: [PATCH 3/3] added exit condition when running this as a .exe, it would close immediately after generating the maze, this is no longer the case. --- 02_Amazing/rust/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/02_Amazing/rust/src/main.rs b/02_Amazing/rust/src/main.rs index a1471a6a..7abc67cf 100644 --- a/02_Amazing/rust/src/main.rs +++ b/02_Amazing/rust/src/main.rs @@ -131,7 +131,6 @@ fn main() { if used[row][col] != 0 {break;} } } - } // Add a random exit col=rng.gen_range(0..width); @@ -163,6 +162,10 @@ fn main() { } println!("."); } + + //stops the program from ending until you give input, useful when running a compiled .exe + println!("\n\npress ENTER to exit"); + io::stdin().read_line(&mut String::new()).expect("closing"); } fn get_user_input(prompt: &str) -> usize {