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 != "devpts"
&& x.fstype != "rpc_pipefs" && x.fstype != "rpc_pipefs"
&& x.fstype != "nfsd" && x.fstype != "nfsd"
&& x.fstype != "swap"
}) })
.collect(); .collect();
if let Some(types) = matches.get_many::<String>("types") { if let Some(types) = matches.get_many::<String>("types") {
for t in types { for t in types {
if t.starts_with("no") { if t.starts_with("no") {
let t = t.strip_prefix("no").unwrap(); let t = t.strip_prefix("no").unwrap();
mntpts = mntpts mntpts.retain(|x| x.fstype != t);
.iter()
.filter(|x| x.fstype != t)
.map(|x| x.clone())
.collect();
} else { } else {
mntpts = mntpts mntpts.retain(|x| &x.fstype == t);
.iter()
.filter(|x| &x.fstype == t)
.map(|x| x.clone())
.collect();
} }
} }
} }