pub struct Sequence { /* private fields */ }
Expand description
A sequence is a generator of ordered integer values.
Implementations§
source§impl Sequence
impl Sequence
sourcepub fn next(&mut self) -> Result<i64, Error>
pub fn next(&mut self) -> Result<i64, Error>
Generate the next value and return it.
The generation algorithm is simple:
- If this is the first time, then return the
start
value. - If the previous value plus the
increment
value is less than theminimum
value or greater than themaximum
value, that is “overflow”, so either raise an error (ifcycle = false
) or return themaximum
value (ifcycle = true
andstep < 0
) or return theminimum
value (ifcycle = true
andstep > 0
).
If there was no error, then save the returned result, it is now the “previous value”.
Auto Trait Implementations§
impl RefUnwindSafe for Sequence
impl Send for Sequence
impl Sync for Sequence
impl Unpin for Sequence
impl UnwindSafe for Sequence
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