summaryrefslogtreecommitdiffstats
path: root/vendor/proptest/src/bits.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/proptest/src/bits.rs
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--vendor/proptest/src/bits.rs17
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);
}