| 1 | use craterust-analyzer cargo fastbloom 0.17.0 crate/::AtomicU64rust-analyzer cargo portable-atomic 1.13.1 AtomicU64#; |
| 2 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::{boxedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/::Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#}; |
| 3 | use portable_atomicrust-analyzer cargo portable-atomic 1.13.1 crate/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#; |
| 4 | |
| 5 | /// A bit vector partitioned in to `u64` blocks. |
| 6 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 7 | #[cfg_attr(feature = "serde", derive(serderust-analyzer cargo serde 1.0.210 crate/::Serializerust-analyzer cargo serde_derive 1.0.210 Serialize:, serderust-analyzer cargo serde 1.0.210 crate/::Deserializerust-analyzer cargo serde_derive 1.0.210 Deserialize:))] |
| 8 | pub(craterust-analyzer cargo fastbloom 0.17.0 crate/) struct BitVecrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec# { |
| 9 | bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec#bits.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[u64]>, |
| 10 | } |
| 11 | |
| 12 | /// A bit vector partitioned in to `u64` blocks. |
| 13 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 14 | #[cfg_attr(feature = "serde", derive(serderust-analyzer cargo serde 1.0.210 crate/::Serializerust-analyzer cargo serde_derive 1.0.210 Serialize:, serderust-analyzer cargo serde 1.0.210 crate/::Deserializerust-analyzer cargo serde_derive 1.0.210 Deserialize:))] |
| 15 | pub(craterust-analyzer cargo fastbloom 0.17.0 crate/) struct AtomicBitVecrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec# { |
| 16 | bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec#bits.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[AtomicU64rust-analyzer cargo portable-atomic 1.13.1 AtomicU64#]>, |
| 17 | } |
| 18 | |
| 19 | macro_rules! impl_bitvecrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl_bitvec! { |
| 20 | ($name:ident, $bits:ty) => { |
| 21 | impl $name { |
| 22 | #[inline(always)] |
| 23 | pub(crate) const fn len(&self) -> usize { |
| 24 | self.bits.len() |
| 25 | } |
| 26 | |
| 27 | #[inline(always)] |
| 28 | pub(crate) const fn num_bits(&self) -> usize { |
| 29 | self.len() * u64::BITS as usize |
| 30 | } |
| 31 | |
| 32 | #[inline(always)] |
| 33 | pub(crate) fn as_slice(&self) -> &[$bits] { |
| 34 | &self.bits |
| 35 | } |
| 36 | |
| 37 | #[inline(always)] |
| 38 | pub(crate) fn iter(&self) -> impl Iterator<Item = u64> + '_ { |
| 39 | self.bits.iter().map(Self::fetch) |
| 40 | } |
| 41 | |
| 42 | #[inline(always)] |
| 43 | pub(crate) fn check(&self, index: usize) -> bool { |
| 44 | let (index, bit) = coord(index); |
| 45 | Self::fetch(&self.bits[index]) & bit > 0 |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | impl FromIterator<u64> for $name { |
| 50 | fn from_iter<I: IntoIterator<Item = u64>>(iter: I) -> Self { |
| 51 | let mut bits = iter.into_iter().map(Self::new).collect::<Vec<_>>(); |
| 52 | bits.shrink_to_fit(); |
| 53 | Self { bits: bits.into() } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | impl PartialEq for $name { |
| 58 | fn eq(&self, other: &Self) -> bool { |
| 59 | if self.len() != other.len() { |
| 60 | return false; |
| 61 | } |
| 62 | core::iter::zip(self.iter(), other.iter()).all(|(l, r)| l == r) |
| 63 | } |
| 64 | } |
| 65 | impl Eq for $name {} |
| 66 | }; |
| 67 | } |
| 68 | |
| 69 | impl_bitvecrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl_bitvec!!(BitVecrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec#, u64); |
| 70 | impl_bitvecrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl_bitvec!!(AtomicBitVecrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec#, AtomicU64rust-analyzer cargo portable-atomic 1.13.1 AtomicU64#); |
| 71 | |
| 72 | impl BitVecrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec# { |
| 73 | #[inline(always)] |
| 74 | fn newrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]new().(x: u64) -> u64 { |
| 75 | x |
| 76 | } |
| 77 | |
| 78 | #[inline(always)] |
| 79 | fn fetchrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]fetch().(x: &u64) -> u64 { |
| 80 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().x |
| 81 | } |
| 82 | |
| 83 | #[inline(always)] |
| 84 | pub(craterust-analyzer cargo fastbloom 0.17.0 crate/) fn setrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]set().(&mut self, index: usize) -> bool { |
| 85 | let (index, bit) = coordrust-analyzer cargo fastbloom 0.17.0 bit_vector/coord().(index); |
| 86 | let previously_contained = self.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand().bit rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0; |
| 87 | self.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOrAssign<Self>`]bitor_assign().bit; |
| 88 | previously_contained |
| 89 | } |
| 90 | |
| 91 | #[inline(always)] |
| 92 | pub(craterust-analyzer cargo fastbloom 0.17.0 crate/) fn clearrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]clear().(&mut self) { |
| 93 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]len().() { |
| 94 | self.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = 0; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | #[inline(always)] |
| 99 | pub(craterust-analyzer cargo fastbloom 0.17.0 crate/) fn unionrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]union().(&mut self, other: &BitVecrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec#) { |
| 100 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(self.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]len().(), other.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]len().(), "expected same length"); |
| 101 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]len().() { |
| 102 | self.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOrAssign<Self>`]bitor_assign().other.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | #[inline(always)] |
| 107 | pub(craterust-analyzer cargo fastbloom 0.17.0 crate/) fn intersectrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]intersect().(&mut self, other: &BitVecrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec#) { |
| 108 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(self.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]len().(), other.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]len().(), "expected same length"); |
| 109 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[BitVec]len().() { |
| 110 | self.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAndAssign<Self>`]bitand_assign().&=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAndAssign<Self>`]bitand_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAndAssign<Self>`]bitand_assign().other.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/BitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | impl AtomicBitVecrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec# { |
| 116 | #[inline] |
| 117 | fn newrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]new().(x: u64) -> AtomicU64rust-analyzer cargo portable-atomic 1.13.1 AtomicU64# { |
| 118 | AtomicU64rust-analyzer cargo portable-atomic 1.13.1 AtomicU64#::newrust-analyzer cargo portable-atomic 1.13.1 impl#[AtomicU64]new().(x) |
| 119 | } |
| 120 | |
| 121 | #[inline] |
| 122 | fn fetchrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]fetch().(x: &AtomicU64rust-analyzer cargo portable-atomic 1.13.1 AtomicU64#) -> u64 { |
| 123 | x.loadrust-analyzer cargo portable-atomic 1.13.1 impl#[AtomicU64]load().(Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#) |
| 124 | } |
| 125 | |
| 126 | #[inline] |
| 127 | pub(craterust-analyzer cargo fastbloom 0.17.0 crate/) fn setrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]set().(&self, index: usize) -> bool { |
| 128 | let (index, bit) = coordrust-analyzer cargo fastbloom 0.17.0 bit_vector/coord().(index); |
| 129 | self.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..fetch_orrust-analyzer cargo portable-atomic 1.13.1 impl#[AtomicU64]fetch_or().(bit, Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitAnd<Self>`]bitand().bit rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0 |
| 130 | } |
| 131 | |
| 132 | #[inline] |
| 133 | pub(craterust-analyzer cargo fastbloom 0.17.0 crate/) fn clearrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]clear().(&self) { |
| 134 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]len().() { |
| 135 | self.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..storerust-analyzer cargo portable-atomic 1.13.1 impl#[AtomicU64]store().(0, Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#); |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | #[inline] |
| 140 | pub(craterust-analyzer cargo fastbloom 0.17.0 crate/) fn unionrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]union().(&self, other: &AtomicBitVecrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec#) { |
| 141 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(self.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]len().(), other.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]len().(), "expected same length"); |
| 142 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]len().() { |
| 143 | let x = other.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..loadrust-analyzer cargo portable-atomic 1.13.1 impl#[AtomicU64]load().(Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#); |
| 144 | self.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..fetch_orrust-analyzer cargo portable-atomic 1.13.1 impl#[AtomicU64]fetch_or().(x, Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | #[inline] |
| 149 | pub(craterust-analyzer cargo fastbloom 0.17.0 crate/) fn intersectrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]intersect().(&self, other: &AtomicBitVecrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec#) { |
| 150 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(self.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]len().(), other.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]len().(), "expected same length"); |
| 151 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.lenrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]len().() { |
| 152 | let x = other.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..loadrust-analyzer cargo portable-atomic 1.13.1 impl#[AtomicU64]load().(Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#); |
| 153 | self.bitsrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec#bits.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..fetch_andrust-analyzer cargo portable-atomic 1.13.1 impl#[AtomicU64]fetch_and().(x, Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#); |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | impl Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# for AtomicBitVecrust-analyzer cargo fastbloom 0.17.0 bit_vector/AtomicBitVec# { |
| 159 | fn clonerust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec][Clone]clone().(&self) -> Selfrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec][Clone] { |
| 160 | self.iterrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl#[AtomicBitVec]iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | #[inline] |
| 165 | fn coordrust-analyzer cargo fastbloom 0.17.0 bit_vector/coord().(index: usize) -> (usize, u64) { |
| 166 | (index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr().6, 1u64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<usize>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<usize>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shl<usize>`]shl().(index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().0b111111)) |
| 167 | } |
| 168 | |
| 169 | macro_rules! impl_testsrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl_tests! { |
| 170 | ($modname:ident, $name:ident) => { |
| 171 | #[allow(unused_mut)] |
| 172 | #[cfg(not(feature = "loom"))] |
| 173 | #[cfg(test)] |
| 174 | mod $modname { |
| 175 | use super::*; |
| 176 | use core::iter::repeat; |
| 177 | |
| 178 | #[test] |
| 179 | fn test_to_from_vec() { |
| 180 | let size = 42; |
| 181 | let b: BitVec = repeat(0).take(size).collect(); |
| 182 | assert_eq!(b.num_bits(), b.len() * 64); |
| 183 | assert!(size <= b.len()); |
| 184 | assert!((size + 64) > b.len()); |
| 185 | } |
| 186 | |
| 187 | #[test] |
| 188 | fn test_only_random_inserts_are_contained() { |
| 189 | let mut vec: BitVec = repeat(0).take(80).collect(); |
| 190 | let mut control = Vec::with_capacity(1000); |
| 191 | let mut rng = fastrand::Rng::with_seed(4364); |
| 192 | |
| 193 | for _ in 0..1000 { |
| 194 | let index = rng.usize(0..vec.num_bits()); |
| 195 | |
| 196 | if !control.contains(&index) { |
| 197 | assert!(!vec.check(index)); |
| 198 | } |
| 199 | control.push(index); |
| 200 | vec.set(index); |
| 201 | assert!(vec.check(index)); |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | }; |
| 206 | } |
| 207 | |
| 208 | impl_testsrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl_tests!!(non_atomicrust-analyzer cargo fastbloom 0.17.0 bit_vector/non_atomic/, BitVec); |
| 209 | impl_testsrust-analyzer cargo fastbloom 0.17.0 bit_vector/impl_tests!!(atomicrust-analyzer cargo fastbloom 0.17.0 bit_vector/atomic/, AtomicBitVec); |