Struct boulder::SampleFromPersianRug
source · [−]pub struct SampleFromPersianRug<T, U, V> { /* private fields */ }
Available on crate feature
persian-rug
only.Expand description
Produce collections of the existing
Proxy<T>
items in the context.
It is safe to add more items, and they will occur in their natural
place in future items yielded by the generator. The generator
argument controls the maximum number of items in each yielded
collection. SampleFromPersianRug
will always return this
maximum if it is possible to do so without duplicating elements.
Example:
use boulder::{GeneratorWithPersianRug, Inc, SampleFromPersianRug};
use persian_rug::{contextual, persian_rug, Context, Proxy};
#[contextual(Rug)]
struct Foo {
a: i32
}
#[persian_rug]
struct Rug(#[table] Foo);
let mut r = Rug(Default::default());
let f1 = r.add(Foo { a: 0 });
let f2 = r.add(Foo { a: 1 });
let mut g = SampleFromPersianRug::<Foo, _, Vec<_>>::new(Inc(0));
let (s1, _) = g.generate(&mut r);
assert_eq!(s1, Vec::new());
let (s2, _) = g.generate(&mut r);
assert_eq!(s2, vec![ f1 ]);
let (s3, _) = g.generate(&mut r);
assert_eq!(s3, vec![ f2, f1 ]);
let (s4, _) = g.generate(&mut r);
assert_eq!(s4, vec![ f2, f1 ]);
Implementations
sourceimpl<C, T, U, V> SampleFromPersianRug<T, U, V> where
U: GeneratorWithPersianRug<C, Output = usize>,
V: FromIterator<Proxy<T>> + 'static,
C: Context + Owner<T>,
T: Contextual<Context = C>,
impl<C, T, U, V> SampleFromPersianRug<T, U, V> where
U: GeneratorWithPersianRug<C, Output = usize>,
V: FromIterator<Proxy<T>> + 'static,
C: Context + Owner<T>,
T: Contextual<Context = C>,
Trait Implementations
sourceimpl<C, T, U, V> GeneratorWithPersianRug<C> for SampleFromPersianRug<T, U, V> where
U: GeneratorWithPersianRug<C, Output = usize>,
V: FromIterator<Proxy<T>> + 'static,
C: Context + Owner<T>,
T: Contextual<Context = C>,
impl<C, T, U, V> GeneratorWithPersianRug<C> for SampleFromPersianRug<T, U, V> where
U: GeneratorWithPersianRug<C, Output = usize>,
V: FromIterator<Proxy<T>> + 'static,
C: Context + Owner<T>,
T: Contextual<Context = C>,
Auto Trait Implementations
impl<T, U, V> RefUnwindSafe for SampleFromPersianRug<T, U, V> where
T: RefUnwindSafe,
U: RefUnwindSafe,
V: RefUnwindSafe,
impl<T, U, V> Send for SampleFromPersianRug<T, U, V> where
T: Send,
U: Send,
V: Send,
impl<T, U, V> Sync for SampleFromPersianRug<T, U, V> where
T: Sync,
U: Sync,
V: Sync,
impl<T, U, V> Unpin for SampleFromPersianRug<T, U, V> where
T: Unpin,
U: Unpin,
V: Unpin,
impl<T, U, V> UnwindSafe for SampleFromPersianRug<T, U, V> where
T: UnwindSafe,
U: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more