pub struct SampledBitSetStrategy<T: BitSetLike> { /* private fields */ }
Expand description
Generates bit sets with a particular number of bits set.
Specifically, this strategy is given both a size range and a bit range. To produce a new value, it selects a size, then uniformly selects that many bits from within the bit range.
Shrinking happens as with BitSetStrategy
.
Implementations§
Source§impl<T: BitSetLike> SampledBitSetStrategy<T>
impl<T: BitSetLike> SampledBitSetStrategy<T>
Sourcepub fn new(size: impl Into<SizeRange>, bits: impl Into<SizeRange>) -> Self
pub fn new(size: impl Into<SizeRange>, bits: impl Into<SizeRange>) -> Self
Create a strategy which generates values where bits within the bounds
given by bits
may be set. The number of bits that are set is chosen
to be in the range given by size
.
Due to the generics, the functions in the typed submodules are usually preferable to calling this directly.
§Panics
Panics if size
includes a value that is greater than the number of
bits in bits
.
Trait Implementations§
Source§impl<T: Clone + BitSetLike> Clone for SampledBitSetStrategy<T>
impl<T: Clone + BitSetLike> Clone for SampledBitSetStrategy<T>
Source§fn clone(&self) -> SampledBitSetStrategy<T>
fn clone(&self) -> SampledBitSetStrategy<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T: Debug + BitSetLike> Debug for SampledBitSetStrategy<T>
impl<T: Debug + BitSetLike> Debug for SampledBitSetStrategy<T>
Source§impl<T: BitSetLike> Strategy for SampledBitSetStrategy<T>
impl<T: BitSetLike> Strategy for SampledBitSetStrategy<T>
Source§type Tree = BitSetValueTree<T>
type Tree = BitSetValueTree<T>
Strategy
.Source§type Value = T
type Value = T
Source§fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self>
Source§fn prop_map<O: Debug, F: Fn(Self::Value) -> O>(self, fun: F) -> Map<Self, F>where
Self: Sized,
fn prop_map<O: Debug, F: Fn(Self::Value) -> O>(self, fun: F) -> Map<Self, F>where
Self: Sized,
fun
. Read moreSource§fn prop_map_into<O: Debug>(self) -> MapInto<Self, O>
fn prop_map_into<O: Debug>(self) -> MapInto<Self, O>
Source§fn prop_perturb<O: Debug, F: Fn(Self::Value, TestRng) -> O>(
self,
fun: F,
) -> Perturb<Self, F>where
Self: Sized,
fn prop_perturb<O: Debug, F: Fn(Self::Value, TestRng) -> O>(
self,
fun: F,
) -> Perturb<Self, F>where
Self: Sized,
fun
, which is additionally given a random number generator. Read moreSource§fn prop_flat_map<S: Strategy, F: Fn(Self::Value) -> S>(
self,
fun: F,
) -> Flatten<Map<Self, F>>where
Self: Sized,
fn prop_flat_map<S: Strategy, F: Fn(Self::Value) -> S>(
self,
fun: F,
) -> Flatten<Map<Self, F>>where
Self: Sized,
Source§fn prop_ind_flat_map<S: Strategy, F: Fn(Self::Value) -> S>(
self,
fun: F,
) -> IndFlatten<Map<Self, F>>where
Self: Sized,
fn prop_ind_flat_map<S: Strategy, F: Fn(Self::Value) -> S>(
self,
fun: F,
) -> IndFlatten<Map<Self, F>>where
Self: Sized,
Source§fn prop_ind_flat_map2<S: Strategy, F: Fn(Self::Value) -> S>(
self,
fun: F,
) -> IndFlattenMap<Self, F>where
Self: Sized,
fn prop_ind_flat_map2<S: Strategy, F: Fn(Self::Value) -> S>(
self,
fun: F,
) -> IndFlattenMap<Self, F>where
Self: Sized,
prop_ind_flat_map()
, but produces 2-tuples with the input
generated from self
in slot 0 and the derived strategy in slot 1. Read moreSource§fn prop_filter<R: Into<Reason>, F: Fn(&Self::Value) -> bool>(
self,
whence: R,
fun: F,
) -> Filter<Self, F>where
Self: Sized,
fn prop_filter<R: Into<Reason>, F: Fn(&Self::Value) -> bool>(
self,
whence: R,
fun: F,
) -> Filter<Self, F>where
Self: Sized,
fun
. Read moreSource§fn prop_filter_map<F: Fn(Self::Value) -> Option<O>, O: Debug>(
self,
whence: impl Into<Reason>,
fun: F,
) -> FilterMap<Self, F>where
Self: Sized,
fn prop_filter_map<F: Fn(Self::Value) -> Option<O>, O: Debug>(
self,
whence: impl Into<Reason>,
fun: F,
) -> FilterMap<Self, F>where
Self: Sized,
fun
returns Some(value)
and rejects those where fun
returns None
. Read moreSource§fn prop_union(self, other: Self) -> Union<Self>where
Self: Sized,
fn prop_union(self, other: Self) -> Union<Self>where
Self: Sized,
Source§fn prop_recursive<R: Strategy<Value = Self::Value> + 'static, F: Fn(BoxedStrategy<Self::Value>) -> R>(
self,
depth: u32,
desired_size: u32,
expected_branch_size: u32,
recurse: F,
) -> Recursive<Self::Value, F>where
Self: Sized + 'static,
fn prop_recursive<R: Strategy<Value = Self::Value> + 'static, F: Fn(BoxedStrategy<Self::Value>) -> R>(
self,
depth: u32,
desired_size: u32,
expected_branch_size: u32,
recurse: F,
) -> Recursive<Self::Value, F>where
Self: Sized + 'static,
self
items as leaves. Read moreSource§fn prop_shuffle(self) -> Shuffle<Self>
fn prop_shuffle(self) -> Shuffle<Self>
Source§fn boxed(self) -> BoxedStrategy<Self::Value>where
Self: Sized + 'static,
fn boxed(self) -> BoxedStrategy<Self::Value>where
Self: Sized + 'static,
Strategy
so it can be passed around as a
simple trait object. Read moreAuto Trait Implementations§
impl<T> Freeze for SampledBitSetStrategy<T>
impl<T> RefUnwindSafe for SampledBitSetStrategy<T>where
T: RefUnwindSafe,
impl<T> Send for SampledBitSetStrategy<T>where
T: Send,
impl<T> Sync for SampledBitSetStrategy<T>where
T: Sync,
impl<T> Unpin for SampledBitSetStrategy<T>where
T: Unpin,
impl<T> UnwindSafe for SampledBitSetStrategy<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes