代码结构优化

This commit is contained in:
JIe 2024-11-20 17:30:57 +08:00
parent c6dcd6b13a
commit 7cd9616cf6

View File

@ -17,12 +17,8 @@ fn filter_by_string(reader: Vec<String>, filter_str: &str) ->Vec<String>{
} }
let mut result: Vec<String> = Vec::new(); let mut result: Vec<String> = Vec::new();
result.push(reader[0].clone()); result.push(reader[0].clone());
for line in reader[1..].iter(){ result.extend(reader.into_iter().skip(1).filter(|line| line.contains(filter_str)));
if line.contains(filter_str){ result
result.push(line.to_string());
}
}
return result;
} }
fn take(reader: &mut Vec<String>, start_index: u32, end_index: u32) -> Vec<String> { fn take(reader: &mut Vec<String>, start_index: u32, end_index: u32) -> Vec<String> {