From 4f56cbd5fe7dd5c4af016944b3c05ba8d5a289fa Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Mon, 15 Apr 2019 14:10:16 +0800 Subject: [PATCH] Use .find() instead of .filter().next() --- src/cli/rustup_mode.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 42b9748b0a..6486e97897 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -1140,8 +1140,7 @@ impl FromStr for CompletionCommand { fn from_str(s: &str) -> std::result::Result { match COMPLETIONS .iter() - .filter(|&(val, _)| val.eq_ignore_ascii_case(s)) - .next() + .find(|&(val, _)| val.eq_ignore_ascii_case(s)) { Some(&(_, cmd)) => Ok(cmd), None => { @@ -1160,7 +1159,7 @@ impl FromStr for CompletionCommand { impl fmt::Display for CompletionCommand { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match COMPLETIONS.iter().filter(|&(_, cmd)| cmd == self).next() { + match COMPLETIONS.iter().find(|&(_, cmd)| cmd == self) { Some(&(val, _)) => write!(f, "{}", val), None => unreachable!(), }