utilbox/umount - use Vec::retain instead of iter/filter/collect

This commit is contained in:
Nathan Fisher 2023-02-06 23:08:46 -05:00
parent 39c3803acb
commit a468b09816

View File

@ -69,23 +69,16 @@ impl Cmd for Umount {
&& x.fstype != "devpts"
&& x.fstype != "rpc_pipefs"
&& x.fstype != "nfsd"
&& x.fstype != "swap"
})
.collect();
if let Some(types) = matches.get_many::<String>("types") {
for t in types {
if t.starts_with("no") {
let t = t.strip_prefix("no").unwrap();
mntpts = mntpts
.iter()
.filter(|x| x.fstype != t)
.map(|x| x.clone())
.collect();
mntpts.retain(|x| x.fstype != t);
} else {
mntpts = mntpts
.iter()
.filter(|x| &x.fstype == t)
.map(|x| x.clone())
.collect();
mntpts.retain(|x| &x.fstype == t);
}
}
}