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

Trait Implementations

Returns the “default value” for a type. Read more

Available on crate feature persian-rug only.

The output type.

Available on crate feature persian-rug only.

Make a new object. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.