pub struct IntegerGenerator<T> { /* private fields */ }Expand description
Generator for integer values. Created by integers().
Bounds default to the type’s full range.
Implementations§
Source§impl<T> IntegerGenerator<T>
impl<T> IntegerGenerator<T>
Sourcepub fn min_value(self, min_value: T) -> Self
pub fn min_value(self, min_value: T) -> Self
Set the minimum value (inclusive).
Examples found in repository?
examples/ledger.rs (line 59)
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 }Sourcepub fn max_value(self, max_value: T) -> Self
pub fn max_value(self, max_value: T) -> Self
Set the maximum value (inclusive).
Examples found in repository?
examples/ledger.rs (line 59)
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 }Trait Implementations§
Source§impl<T: Integer + DeserializeOwned + Serialize + Send + Sync + 'static> Generator<T> for IntegerGenerator<T>
impl<T: Integer + DeserializeOwned + Serialize + Send + Sync + 'static> Generator<T> for IntegerGenerator<T>
Source§fn map<U, F>(self, f: F) -> Mapped<T, U, F, Self>
fn map<U, F>(self, f: F) -> Mapped<T, U, F, Self>
Transform generated values using a function. Read more
Source§fn flat_map<U, G, F>(self, f: F) -> FlatMapped<T, U, G, F, Self>
fn flat_map<U, G, F>(self, f: F) -> FlatMapped<T, U, G, F, Self>
Generate a value, then use it to choose or configure another generator. Read more
Auto Trait Implementations§
impl<T> Freeze for IntegerGenerator<T>where
T: Freeze,
impl<T> RefUnwindSafe for IntegerGenerator<T>where
T: RefUnwindSafe,
impl<T> Send for IntegerGenerator<T>where
T: Send,
impl<T> Sync for IntegerGenerator<T>where
T: Sync,
impl<T> Unpin for IntegerGenerator<T>where
T: Unpin,
impl<T> UnsafeUnpin for IntegerGenerator<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for IntegerGenerator<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