From 8123d8d867af2ceff6c93c75b85f156bac9b794e Mon Sep 17 00:00:00 2001 From: Darrel Malkin Date: Thu, 31 Oct 2024 16:35:06 +1100 Subject: [PATCH] Changed OS-based Line Ending Trimming - Changed the OS-based line ending trimming, and used just trim() --- src/main.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index dd8f143..40b3e0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,15 +13,8 @@ fn main() { let mut saveLocInput = String::new(); io::stdin().read_line(&mut saveLocInput).expect("Error recieving User Input"); - let mut saveLoc = ""; // The read_line collects line endings, so we need to remove them. - // This varies across different OS' though, so I've split it - // into Unix and Windows - if cfg!(windows) { - saveLoc = saveLocInput.strip_suffix("\r\n").unwrap(); - } else if cfg!(unix) { - saveLoc = saveLocInput.strip_suffix("\n").unwrap(); - } + let saveLoc = saveLocInput.trim(); let saveFile = Save::load(saveLoc).unwrap(); saveFile.print();