I have a hard time fixing the needless collect clippy warning.
pub fn import_selection(packages: &mut Vec<PackageRow>) -> io::Result<()> {
let file = fs::File::open("uad_exported_selection.txt")?;
let reader = BufReader::new(file);
let imported_selection: Vec<String> = reader
.lines()
.map(|l| l.expect("Could not exported selection"))
.collect();
for (i,p) in packages.iter_mut().enumerate() {
if imported_selection.contains(&p.name) {
p.selected = true;
...
} else {
p.selected = false;
}
}
Ok(())
}
I tried to use any()
directly from the iterator, it compiles but doesn't seems to work (it doesn't find anything when it should)
Is it really possible to remove the collect in this case?