From 6ba0a2d7e205a104f36cf447c0b18f5334802ff0 Mon Sep 17 00:00:00 2001 From: AnthonyMichaelTDM <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Wed, 9 Mar 2022 13:25:36 -0800 Subject: [PATCH] bug fix --- 00_Utilities/mardown_todo_rust/src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/00_Utilities/mardown_todo_rust/src/main.rs b/00_Utilities/mardown_todo_rust/src/main.rs index 005368df..12ac5e8e 100644 --- a/00_Utilities/mardown_todo_rust/src/main.rs +++ b/00_Utilities/mardown_todo_rust/src/main.rs @@ -37,12 +37,12 @@ fn main() { Markdown TODO list maker by Anthony Rubick for the basic-computer-games repo - + "); //ask user how they want the todo list formatted - format_game_first = get_yn_from_user("\n\t---====FORMATS====---\ngame first:\n\tGame\n\t\tLanguage ✅/⬜️\n\nlang first:\n\tLanguage\n\t\tGame ✅/⬜️\n\nmake todo list using the game first format? (y/n)"); + format_game_first = get_yn_from_user("\n\t---====FORMATS====---\ngame first:\n\tGame\n\t\tLanguage ✅/⬜️\n\nlang first:\n\tLanguage\n\t\tGame ✅/⬜️\n\nmake todo list using the game first format? (y/n | default No) "); //get all folders in ROOT_DIR root_folders = Vec::new(); @@ -209,8 +209,14 @@ fn get_str_from_user(prompt:&str) -> String { * gets a boolean from user */ fn get_yn_from_user(prompt:&str) -> bool { + //DATA + let input = get_str_from_user(prompt); + + //default in case of error + if input.is_empty() {return false;} + //get and parse input - match &get_str_from_user(prompt)[0..1] { //get first character + match &input[0..1] { //get first character "y" | "Y" => return true, _ => return false, }