diff --git a/crates/formality-rust/src/grammar.rs b/crates/formality-rust/src/grammar.rs index 37cef86b..35a8403d 100644 --- a/crates/formality-rust/src/grammar.rs +++ b/crates/formality-rust/src/grammar.rs @@ -34,7 +34,7 @@ impl Program { _ => None, }) .collect(); - if traits.len() < 1 { + if traits.is_empty() { anyhow::bail!("no trait named `{trait_id:?}`") } else if traits.len() > 1 { anyhow::bail!("multiple traits named `{trait_id:?}`") diff --git a/crates/formality-types/src/collections.rs b/crates/formality-types/src/collections.rs index bf61b5a7..8f33a485 100644 --- a/crates/formality-types/src/collections.rs +++ b/crates/formality-types/src/collections.rs @@ -69,11 +69,7 @@ pub trait SetExt: Sized { impl SetExt for Set { fn split_first(self) -> Option<(T, Set)> { let mut iter = self.into_iter(); - if let Some(e) = iter.next() { - Some((e, iter.collect())) - } else { - None - } + iter.next().map(|e| (e, iter.collect())) } fn union_with(mut self, other: Self) -> Self {