pub struct Variables<T> { /* private fields */ }Expand description
A pool of previously generated values.
Implementations§
Source§impl<T> Variables<T>
impl<T> Variables<T>
Sourcepub fn draw(&self) -> &T
pub fn draw(&self) -> &T
Draw a reference to a value from the pool (without removing it).
Calls assume(false) if the pool is empty.
Examples found in repository?
examples/ledger.rs (line 58)
57 fn credit(&mut self, tc: TestCase) {
58 let account = self.accounts.draw().clone();
59 let amount = tc.draw(gs::integers::<i64>().min_value(0).max_value(LIMIT));
60 tc.note(&format!("credit '{}' with {}", account.clone(), amount));
61 self.ledger.credit(account, amount);
62 }
63
64 #[rule]
65 fn transfer(&mut self, tc: TestCase) {
66 let from = self.accounts.draw().clone();
67 let to = self.accounts.draw().clone();
68 let amount = tc.draw(gs::integers::<i64>().min_value(0).max_value(LIMIT));
69 tc.note(&format!(
70 "transfer '{}' from {} to {}",
71 amount,
72 from.clone(),
73 to.clone()
74 ));
75 self.ledger.transfer(from, to, amount);
76 }Auto Trait Implementations§
impl<T> !Freeze for Variables<T>
impl<T> !RefUnwindSafe for Variables<T>
impl<T> Send for Variables<T>where
T: Send,
impl<T> !Sync for Variables<T>
impl<T> Unpin for Variables<T>where
T: Unpin,
impl<T> UnsafeUnpin for Variables<T>
impl<T> !UnwindSafe for Variables<T>
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