diff options
Diffstat (limited to '')
-rw-r--r-- | vendor/proptest/src/bits.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/vendor/proptest/src/bits.rs b/vendor/proptest/src/bits.rs index 342eb28b1..89b183ed1 100644 --- a/vendor/proptest/src/bits.rs +++ b/vendor/proptest/src/bits.rs @@ -22,6 +22,8 @@ use core::mem; #[cfg(feature = "bit-set")] use bit_set::BitSet; +#[cfg(feature = "bit-set")] +use bit_vec::BitVec; use rand::{self, seq::IteratorRandom, Rng}; use crate::collection::SizeRange; @@ -450,8 +452,15 @@ pub(crate) mod varsize { impl VarBitSet { /// Create a bit set of `len` set values. + #[cfg(not(feature = "bit-set"))] + pub fn saturated(len: usize) -> Self { + Self(vec![true; len]) + } + + /// Create a bit set of `len` set values. + #[cfg(feature = "bit-set")] pub fn saturated(len: usize) -> Self { - (0..len).collect::<VarBitSet>() + Self(BitSet::from_bit_vec(BitVec::from_elem(len, true))) } #[cfg(not(feature = "bit-set"))] @@ -492,8 +501,10 @@ pub(crate) mod varsize { } impl FromIterator<usize> for VarBitSet { - fn from_iter<T: IntoIterator<Item = usize>>(iter: T) -> Self { - let mut bits = VarBitSet::new_bitset(0); + fn from_iter<T: IntoIterator<Item = usize>>(into_iter: T) -> Self { + let iter = into_iter.into_iter(); + let lower_bound = iter.size_hint().0; + let mut bits = VarBitSet::new_bitset(lower_bound); for bit in iter { bits.set(bit); } |