diff --git a/src/map.rs b/src/map.rs index 245b1d9d1f..ee6c14ad4f 100644 --- a/src/map.rs +++ b/src/map.rs @@ -846,7 +846,7 @@ where Some(item) => unsafe { let &(ref key, ref value) = item.as_ref(); Some((key, value)) - } + }, None => None, } } @@ -886,7 +886,7 @@ where Some(item) => unsafe { let &mut (ref key, ref mut value) = item.as_mut(); Some((key, value)) - } + }, None => None, } } @@ -1390,8 +1390,15 @@ where fn next(&mut self) -> Option { self.inner.next(&mut self.f) } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (0, self.inner.iter.size_hint().1) + } } +impl FusedIterator for DrainFilter<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool {} + /// Portions of `DrainFilter` shared with `set::DrainFilter` pub(super) struct DrainFilterInner<'a, K, V> { pub iter: RawIter<(K, V)>, @@ -1585,7 +1592,7 @@ impl<'a, K, V, S> RawEntryBuilder<'a, K, V, S> { Some(item) => unsafe { let &(ref key, ref value) = item.as_ref(); Some((key, value)) - } + }, None => None, } } @@ -2055,7 +2062,7 @@ impl<'a, K, V> Iterator for Iter<'a, K, V> { Some(x) => unsafe { let r = x.as_ref(); Some((&r.0, &r.1)) - } + }, None => None, } } @@ -2083,7 +2090,7 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> { Some(x) => unsafe { let r = x.as_mut(); Some((&r.0, &mut r.1)) - } + }, None => None, } } diff --git a/src/raw/mod.rs b/src/raw/mod.rs index 1ff0135382..01fcaae0bf 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -406,7 +406,7 @@ impl RawTable { // Avoid `Option::ok_or_else` because it bloats LLVM IR. let (layout, ctrl_offset) = match calculate_layout::(buckets) { Some(lco) => lco, - None => return Err(fallability.capacity_overflow()) + None => return Err(fallability.capacity_overflow()), }; let ptr = match NonNull::new(alloc(layout)) { Some(ptr) => ptr, @@ -688,7 +688,10 @@ impl RawTable { *self = Self::with_capacity(min_size) } else { // Avoid `Result::unwrap_or_else` because it bloats LLVM IR. - if self.resize(min_size, hasher, Fallibility::Infallible).is_err() { + if self + .resize(min_size, hasher, Fallibility::Infallible) + .is_err() + { unsafe { hint::unreachable_unchecked() } } } @@ -701,7 +704,10 @@ impl RawTable { pub fn reserve(&mut self, additional: usize, hasher: impl Fn(&T) -> u64) { if additional > self.growth_left { // Avoid `Result::unwrap_or_else` because it bloats LLVM IR. - if self.reserve_rehash(additional, hasher, Fallibility::Infallible).is_err() { + if self + .reserve_rehash(additional, hasher, Fallibility::Infallible) + .is_err() + { unsafe { hint::unreachable_unchecked() } } } @@ -1114,7 +1120,7 @@ impl Clone for RawTable { match Self::new_uninitialized(self.buckets(), Fallibility::Infallible) { Ok(table) => table, Err(_) => hint::unreachable_unchecked(), - } + }, ); new_table.clone_from_spec(self, |new_table| { @@ -1151,7 +1157,7 @@ impl Clone for RawTable { match Self::new_uninitialized(source.buckets(), Fallibility::Infallible) { Ok(table) => table, Err(_) => hint::unreachable_unchecked(), - } + }, ); } diff --git a/src/set.rs b/src/set.rs index 21cfeb90bd..12e01f50c4 100644 --- a/src/set.rs +++ b/src/set.rs @@ -1462,8 +1462,15 @@ where let (k, _) = self.inner.next(&mut |k, _| f(k))?; Some(k) } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (0, self.inner.iter.size_hint().1) + } } +impl FusedIterator for DrainFilter<'_, K, F> where F: FnMut(&K) -> bool {} + impl Clone for Intersection<'_, T, S> { #[cfg_attr(feature = "inline-more", inline)] fn clone(&self) -> Self {