From 46e2859d28fe7aaca3736195dae2b76b56603daf Mon Sep 17 00:00:00 2001 From: aggarwalakshun Date: Wed, 30 Apr 2025 17:59:48 +0530 Subject: [PATCH] trim whitespaces --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index b1f8eda..4928ce3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,7 @@ fn main() -> io::Result<()> { let buffer = std::str::from_utf8(&file_content.data) .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; - let first_choice: Vec = buffer.lines().map(|line| line.to_string()).collect(); + let first_choice: Vec = buffer.lines().map(|line| line.trim().to_string()).collect(); for (index, element) in first_choice.iter().enumerate() { eprint!("{}. {}\n", index + 1, element); @@ -103,7 +103,7 @@ fn install_programs() -> Result<(), Box> { let file = Asset::get("prompts/programs.txt").ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "File not found"))?; let buffer = std::str::from_utf8(&file.data) .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; - let choice: Vec = buffer.lines().map(|line| line.to_string()).collect(); + let choice: Vec = buffer.lines().map(|line| line.trim().to_string()).collect(); for(index, element) in choice.iter().enumerate() { eprint!("{}. {}\n", index+1, element) @@ -249,7 +249,7 @@ fn aur() -> Result<(), Box> { let file = Asset::get("prompts/aur.txt").ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "File not found"))?; let buffer = std::str::from_utf8(&file.data) .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; - let choice: Vec = buffer.lines().map(|line| line.to_string()).collect(); + let choice: Vec = buffer.lines().map(|line| line.trim().to_string()).collect(); if which("yay").is_none() { eprint!("yay not found. Install yay Y/N? (1/0)"); @@ -295,7 +295,7 @@ fn third_party() -> Result<(), Box> { let buffer = std::str::from_utf8(&file.data) .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; - let choices: Vec = buffer.lines().map(|line| line.to_string()).collect(); + let choices: Vec = buffer.lines().map(|line| line.trim().to_string()).collect(); for (index, element) in choices.iter().enumerate() { eprintln!("{}. {}", index + 1, element);