Struct boulder::RepeatFromPersianRug
source · [−]pub struct RepeatFromPersianRug<T> { /* private fields */ }
Available on crate feature
persian-rug
only.Expand description
Cycle through the existing Proxy<T>
items
in the context.
Each proxy will be yielded in turn, in insertion order, and then the sequence will repeat. It is safe to insert more values to yield, and they will occur in their natural position when they are reached.
generate
routine will panic if
there are no available items.
Example:
use boulder::{GeneratorWithPersianRug, RepeatFromPersianRug};
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());
r.add(Foo { a: 0 });
r.add(Foo { a: 1 });
let mut g = RepeatFromPersianRug::<Foo>::new();
let (f1, _) = g.generate(&mut r);
assert_eq!(r.get(&f1).a, 0);
let (f2, _) = g.generate(&mut r);
assert_eq!(r.get(&f2).a, 1);
let (f3, _) = g.generate(&mut r);
assert_eq!(f1, f3);
r.add(Foo { a: 2} );
let (f4, _) = g.generate(&mut r);
assert_eq!(f2, f4);
let (f5, _) = g.generate(&mut r);
assert_eq!(r.get(&f5).a, 2);
Implementations
sourceimpl<T> RepeatFromPersianRug<T>
impl<T> RepeatFromPersianRug<T>
Trait Implementations
sourceimpl<T> Default for RepeatFromPersianRug<T>
impl<T> Default for RepeatFromPersianRug<T>
sourceimpl<C, T> GeneratorWithPersianRug<C> for RepeatFromPersianRug<T> where
C: Context + Owner<T>,
T: Contextual<Context = C>,
impl<C, T> GeneratorWithPersianRug<C> for RepeatFromPersianRug<T> where
C: Context + Owner<T>,
T: Contextual<Context = C>,
Auto Trait Implementations
impl<T> RefUnwindSafe for RepeatFromPersianRug<T> where
T: RefUnwindSafe,
impl<T> Send for RepeatFromPersianRug<T> where
T: Send,
impl<T> Sync for RepeatFromPersianRug<T> where
T: Sync,
impl<T> Unpin for RepeatFromPersianRug<T> where
T: Unpin,
impl<T> UnwindSafe for RepeatFromPersianRug<T> where
T: 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