pub struct TryRepeatFromPersianRug<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.
If there are no available items,
generate returns None.
Example:
use boulder::{GeneratorWithPersianRug, TryRepeatFromPersianRug};
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 mut g = TryRepeatFromPersianRug::<Foo>::new();
let (f0, _) = g.generate(&mut r);
assert!(f0.is_none());
r.add(Foo { a: 0 });
r.add(Foo { a: 1 });
let (f1, _) = g.generate(&mut r);
assert_eq!(r.get(&f1.unwrap()).a, 0);
let (f2, _) = g.generate(&mut r);
assert_eq!(r.get(&f2.unwrap()).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.unwrap()).a, 2);Implementations§
Source§impl<T> TryRepeatFromPersianRug<T>
impl<T> TryRepeatFromPersianRug<T>
Trait Implementations§
Source§impl<T> Default for TryRepeatFromPersianRug<T>
impl<T> Default for TryRepeatFromPersianRug<T>
Source§impl<C, T> GeneratorWithPersianRug<C> for TryRepeatFromPersianRug<T>
impl<C, T> GeneratorWithPersianRug<C> for TryRepeatFromPersianRug<T>
Auto Trait Implementations§
impl<T> Freeze for TryRepeatFromPersianRug<T>
impl<T> RefUnwindSafe for TryRepeatFromPersianRug<T>where
T: RefUnwindSafe,
impl<T> Send for TryRepeatFromPersianRug<T>where
T: Send,
impl<T> Sync for TryRepeatFromPersianRug<T>where
T: Sync,
impl<T> Unpin for TryRepeatFromPersianRug<T>where
T: Unpin,
impl<T> UnwindSafe for TryRepeatFromPersianRug<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
Mutably borrows from an owned value. Read more