Struct checkito::size::Size

source ·
pub struct Size<G, F = fn(_: f64) -> f64>(pub G, pub F);

Tuple Fields§

§0: G§1: F

Trait Implementations§

source§

impl<G: Generate, F: Fn(f64) -> f64> Generate for Size<G, F>

source§

type Item = <G as Generate>::Item

source§

type Shrink = <G as Generate>::Shrink

source§

fn generate(&self, state: &mut State) -> Self::Shrink

Primary method of this trait. It generates a Shrink instance that will be able to produce values of type Generate::Item and shrink itself.
source§

fn boxed(self) -> Generator<Self::Item>
where Self: Sized + 'static, Generator<Self::Item>: Generate,

Wraps self in a boxed Generate. This is notably relevant for recursive Generate implementations where the type would otherwise be infinite. Read more
source§

fn map<T, F: Fn(Self::Item) -> T>(self, map: F) -> Map<Self, F>
where Self: Sized, Map<Self, F>: Generate,

Maps generated Generate::Item to an arbitrary type T using the provided function F.
source§

fn filter<F: Fn(&Self::Item) -> bool>(self, filter: F) -> Filter<Self, F>
where Self: Sized, Filter<Self, F>: Generate,

Same as Generate::filter_with but with a predefined number of retries.
source§

fn filter_with<F: Fn(&Self::Item) -> bool>( self, retries: usize, filter: F, ) -> Filter<Self, F>
where Self: Sized, Filter<Self, F>: Generate,

Generates many Generate::Item with an increasingly large size until the filter function F is satisfied, up to the maximum number of retries. Read more
source§

fn filter_map<T, F: Fn(Self::Item) -> Option<T>>( self, map: F, ) -> FilterMap<Self, F>
where Self: Sized, FilterMap<Self, F>: Generate,

Same as Generate::filter_map_with but with a predefined number of retries.
source§

fn filter_map_with<T, F: Fn(Self::Item) -> Option<T>>( self, retries: usize, map: F, ) -> FilterMap<Self, F>
where Self: Sized, FilterMap<Self, F>: Generate,

Combines Generate::map and Generate::filter in a single Generate implementation where the map function is considered to satisfy the filter when a [Some(T)] is produced.
source§

fn flat_map<G: Generate, F: Fn(Self::Item) -> G>( self, map: F, ) -> Flatten<Map<Self, F>>
where Self: Sized, Map<Self, F>: Generate<Item = G>, Flatten<Map<Self, F>>: Generate,

Combines Generate::map and Generate::flatten in a single Generate implementation.
source§

fn array<const N: usize>(self) -> Array<Self, N>
where Self: Sized, Array<Self, N>: Generate,

Generates N items and fills an array with it.
source§

fn collect<F: FromIterator<Self::Item>>(self) -> Collect<Self, Range<usize>, F>
where Self: Sized, Collect<Self, Range<usize>, F>: Generate,

Same as Generate::collect_with but with a predefined count.
source§

fn collect_with<C: Generate<Item = usize>, F: FromIterator<Self::Item>>( self, count: C, ) -> Collect<Self, C, F>
where Self: Sized, Collect<Self, C, F>: Generate,

Generates a variable number of items based on the provided count Generate and then builds a value of type F based on its implementation of FromIterator.
source§

fn size<F: Fn(f64, usize) -> f64>(self, map: F) -> Size<Self, F>
where Self: Sized, Size<Self, F>: Generate,

Maps the current size of the generation process to a different one. The size is a value in the range [0.0..1.0] that represents how big the generated items are based on the generator’s constraints. The generation process will initially try to produce small items and then move on to bigger ones. Note that the size does not guarantee a small or big generated item since Generate implementations are free to interpret it as they wish, although that is its intention. Read more
source§

fn dampen(self) -> Dampen<Self>
where Self: Sized, Size<Self>: Generate,

Same as Generate::dampen_with but with predefined arguments.
source§

fn dampen_with( self, pressure: f64, deepest: usize, limit: usize, ) -> Dampen<Self>
where Self: Sized, Dampen<Self>: Generate,

Dampens the size (see Generate::size for more information about size) as items are generated. Read more
source§

fn keep(self) -> Keep<Self>
where Self: Sized, Keep<Self>: Generate,

Keeps the generated items intact through the shrinking process (i.e. un-shrinked).
source§

fn sampler(&self) -> Sampler<'_, Self>

Provides a Sampler that allows to configure sampling settings and generate samples.
source§

fn samples(&self, count: usize) -> Samples<'_, Self>

Generates count random values the are progressively larger in size. For additional sampling settings, see Generate::sampler.
source§

fn sample(&self, size: f64) -> Self::Item

Generates a random value of size (0.0..=1.0). For additional sampling settings, see Generate::sampler.
source§

fn checker(&self) -> Checker<'_, Self>

source§

fn checks<P: Prove, F: FnMut(&Self::Item) -> P>( &self, count: usize, check: F, ) -> Checks<'_, Self, F>

source§

fn check<P: Prove, F: FnMut(&Self::Item) -> P>( &self, count: usize, check: F, ) -> Result<(), Error<Self::Item, P>>

source§

impl<S: IntoShrink, F> IntoShrink for Size<S, F>

source§

type Item = <S as IntoShrink>::Item

source§

type Shrink = <S as IntoShrink>::Shrink

source§

fn shrinker(&self, item: Self::Item) -> Option<Self::Shrink>

Auto Trait Implementations§

§

impl<G, F> Freeze for Size<G, F>
where G: Freeze, F: Freeze,

§

impl<G, F> RefUnwindSafe for Size<G, F>

§

impl<G, F> Send for Size<G, F>
where G: Send, F: Send,

§

impl<G, F> Sync for Size<G, F>
where G: Sync, F: Sync,

§

impl<G, F> Unpin for Size<G, F>
where G: Unpin, F: Unpin,

§

impl<G, F> UnwindSafe for Size<G, F>
where G: UnwindSafe, F: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.