pub enum SGen<A> {
Sized(Rc<RefCell<dyn Fn(u32) -> Gen<A>>>),
Unsized(Gen<A>),
}Expand description
Generator with size information.
Variants§
Sized(Rc<RefCell<dyn Fn(u32) -> Gen<A>>>)
Generator with size information.
Unsized(Gen<A>)
Generator without size information.
Implementations§
Source§impl<A: Clone + 'static> SGen<A>
impl<A: Clone + 'static> SGen<A>
Sourcepub fn of_sized<F>(f: F) -> SGen<A>
pub fn of_sized<F>(f: F) -> SGen<A>
Creates a sized generator that can produce different Gens based on a size parameter.
§Arguments
f- A function that takes a size parameter and returns a Gen
§Returns
- An
SGen<A>that can generate size-dependent values
§Type Parameters
F- The function type, must be Fn(u32) -> Gen + ’static
§Examples
use prop_check_rs::gen::SGen;
use prop_check_rs::gen::Gens;
let sized_gen = SGen::of_sized(|size| Gens::list_of_n(size as usize, Gens::choose(1, 10)));Sourcepub fn of_unsized(gen: Gen<A>) -> SGen<A>
pub fn of_unsized(gen: Gen<A>) -> SGen<A>
Sourcepub fn run(&self, i: Option<u32>) -> Gen<A>
pub fn run(&self, i: Option<u32>) -> Gen<A>
Runs the generator with an optional size parameter to produce a Gen.
§Arguments
i- Optional size parameter, required for Sized variants
§Returns
- A
Gen<A>that can generate values
§Panics
- Panics if a Sized variant is run without a size parameter
§Examples
use prop_check_rs::gen::SGen;
use prop_check_rs::gen::Gens;
let sized_gen = SGen::of_sized(|n| Gens::list_of_n(n as usize, Gens::pure(1)));
let gen = sized_gen.run(Some(5)); // Creates a Gen that produces a vector of 5 onesTrait Implementations§
Auto Trait Implementations§
impl<A> Freeze for SGen<A>
impl<A> !RefUnwindSafe for SGen<A>
impl<A> !Send for SGen<A>
impl<A> !Sync for SGen<A>
impl<A> Unpin for SGen<A>
impl<A> !UnwindSafe for SGen<A>
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
Mutably borrows from an owned value. Read more