From cd015e97f1b6baeb0008689834b881480105c493 Mon Sep 17 00:00:00 2001 From: Piotr Czarnecki Date: Sat, 29 Jun 2024 21:52:44 +0200 Subject: [PATCH] Format with rustfmt --- src/lib.rs | 80 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 09ae4ef..5795e7a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -499,8 +499,8 @@ impl BitSet { set: self.bit_vec.blocks(), other: other.bit_vec.blocks(), merge: bitand, - }), - n: min + }), + n: min, } } @@ -890,7 +890,7 @@ pub struct Intersection<'a, B: 'a> { // number of elements in the intersection, and count it // down as we return elements. If we reach zero, we can // stop. - n: usize + n: usize, } #[derive(Clone)] pub struct Difference<'a, B: 'a>(BlockIter, B>); @@ -927,7 +927,6 @@ where self.head.count_ones() + self.tail.map(|block| block.count_ones()).sum::() } - #[inline] fn size_hint(&self) -> (usize, Option) { match self.tail.size_hint() { @@ -966,31 +965,51 @@ impl<'a, B: BitBlock> Iterator for TwoBitPositions<'a, B> { impl<'a, B: BitBlock> Iterator for Iter<'a, B> { type Item = usize; - #[inline] fn next(&mut self) -> Option { self.0.next() } - #[inline] fn size_hint(&self) -> (usize, Option) { self.0.size_hint() } - #[inline] fn count(self) -> usize { self.0.count() } + #[inline] + fn next(&mut self) -> Option { + self.0.next() + } + #[inline] + fn size_hint(&self) -> (usize, Option) { + self.0.size_hint() + } + #[inline] + fn count(self) -> usize { + self.0.count() + } } impl<'a, B: BitBlock> Iterator for Union<'a, B> { type Item = usize; - #[inline] fn next(&mut self) -> Option { self.0.next() } - #[inline] fn size_hint(&self) -> (usize, Option) { self.0.size_hint() } - #[inline] fn count(self) -> usize { self.0.count() } + #[inline] + fn next(&mut self) -> Option { + self.0.next() + } + #[inline] + fn size_hint(&self) -> (usize, Option) { + self.0.size_hint() + } + #[inline] + fn count(self) -> usize { + self.0.count() + } } impl<'a, B: BitBlock> Iterator for Intersection<'a, B> { type Item = usize; - #[inline] fn next(&mut self) -> Option { + #[inline] + fn next(&mut self) -> Option { if self.n != 0 { self.n -= 1; - self.iter.next() + self.iter.next() } else { None } } - #[inline] fn size_hint(&self) -> (usize, Option) { + #[inline] + fn size_hint(&self) -> (usize, Option) { // We could invoke self.iter.size_hint() and incorporate that into the hint. // In practice, that does not seem worthwhile because the lower bound will // always be zero and the upper bound could only possibly less then n in a @@ -998,23 +1017,44 @@ impl<'a, B: BitBlock> Iterator for Intersection<'a, B> { // in a partially iterated iterator, so it did not seem worthwhile. (0, Some(self.n)) } - #[inline] fn count(self) -> usize { self.iter.count() } + #[inline] + fn count(self) -> usize { + self.iter.count() + } } impl<'a, B: BitBlock> Iterator for Difference<'a, B> { type Item = usize; - #[inline] fn next(&mut self) -> Option { self.0.next() } - #[inline] fn size_hint(&self) -> (usize, Option) { self.0.size_hint() } - #[inline] fn count(self) -> usize { self.0.count() } + #[inline] + fn next(&mut self) -> Option { + self.0.next() + } + #[inline] + fn size_hint(&self) -> (usize, Option) { + self.0.size_hint() + } + #[inline] + fn count(self) -> usize { + self.0.count() + } } impl<'a, B: BitBlock> Iterator for SymmetricDifference<'a, B> { type Item = usize; - #[inline] fn next(&mut self) -> Option { self.0.next() } - #[inline] fn size_hint(&self) -> (usize, Option) { self.0.size_hint() } - #[inline] fn count(self) -> usize { self.0.count() } + #[inline] + fn next(&mut self) -> Option { + self.0.next() + } + #[inline] + fn size_hint(&self) -> (usize, Option) { + self.0.size_hint() + } + #[inline] + fn count(self) -> usize { + self.0.count() + } } impl<'a, B: BitBlock> IntoIterator for &'a BitSet {