Minor iterator changes

This commit is contained in:
David Peter
2024-12-20 09:40:43 +01:00
parent 0d6425ae4e
commit b85a56db5b
2 changed files with 4 additions and 8 deletions

View File

@@ -379,16 +379,12 @@ mod tests {
impl UseDefMap<'_> {
fn first_public_binding(&self, symbol: ScopedSymbolId) -> Option<Definition<'_>> {
self.public_bindings(symbol)
.map(|constrained_binding| constrained_binding.binding)
.find(Option::is_some)
.unwrap()
.find_map(|constrained_binding| constrained_binding.binding)
}
fn first_binding_at_use(&self, use_id: ScopedUseId) -> Option<Definition<'_>> {
self.bindings_at_use(use_id)
.map(|constrained_binding| constrained_binding.binding)
.find(Option::is_some)
.unwrap()
.find_map(|constrained_binding| constrained_binding.binding)
}
}

View File

@@ -392,7 +392,7 @@ fn declarations_ty<'db>(
let mut conflicting: Vec<Type<'db>> = vec![];
let declared_ty = if let Some(second) = types.next() {
let mut builder = UnionBuilder::new(db).add(first);
for other in [second].into_iter().chain(types) {
for other in std::iter::once(second).chain(types) {
if !first.is_equivalent_to(db, other) {
conflicting.push(other);
}
@@ -415,7 +415,7 @@ fn declarations_ty<'db>(
} else {
Err((
declared_ty,
[first].into_iter().chain(conflicting).collect(),
std::iter::once(first).chain(conflicting).collect(),
))
}
} else {