style: code style

This commit is contained in:
2020-07-26 17:41:20 +08:00
parent a175d49385
commit a864b897c3

View File

@@ -36,14 +36,10 @@ fn main() -> std::io::Result<()> {
main_legacy()
} else {
let mut tokens : Vec<Token> = 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<String> {
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<P>(filename: P) -> io::Result<Lines<BufReader<File>>> where P: AsRef<Path> {
let file = match File::open(&filename) {
Ok(line) => line,