From a468b0981692f53dcd3fa772d920573887906882 Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Mon, 6 Feb 2023 23:08:46 -0500 Subject: [PATCH] utilbox/umount - use Vec::retain instead of iter/filter/collect --- utilbox/commands/umount/mod.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/utilbox/commands/umount/mod.rs b/utilbox/commands/umount/mod.rs index 9378c46..2e1aebf 100644 --- a/utilbox/commands/umount/mod.rs +++ b/utilbox/commands/umount/mod.rs @@ -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::("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); } } }