diff --git a/src/main.rs b/src/main.rs index 2e6fc70..84f8d9f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,14 +36,10 @@ fn main() -> std::io::Result<()> { main_legacy() } else { let mut tokens : Vec = vec![]; + let mut togo_config_path = String::from(dirs::home_dir().unwrap().to_str().unwrap()); togo_config_path.push_str("/.cargo/todo_config"); - - let mut regex = vec![]; - for line in read_lines(togo_config_path).unwrap() { - let line = line.unwrap(); - if !line.is_empty() { regex.push(line) }; - } + let regex = read_lines_to_vec(&togo_config_path); let mut all_rs_path = String::from(env::current_dir().unwrap().to_str().unwrap()); all_rs_path.push_str("/**/*.rs"); @@ -129,6 +125,15 @@ fn main() -> std::io::Result<()> { } } +fn read_lines_to_vec(file_name: &str) -> Vec { + let mut regex = vec![]; + for line in read_lines(file_name).unwrap() { + let line = line.unwrap(); + if !line.is_empty() { regex.push(line) }; + } + return regex; +} + fn read_lines

(filename: P) -> io::Result>> where P: AsRef { let file = match File::open(&filename) { Ok(line) => line,