pub struct Repetition { /* private fields */ }Expand description
Represents a range or a fixed number
the upper limit is optionally defined
Implementations§
Source§impl Repetition
impl Repetition
Sourcepub fn range(min: usize, max: Option<usize>) -> Result<Self, InvalidRepetition>
pub fn range(min: usize, max: Option<usize>) -> Result<Self, InvalidRepetition>
Creates a new repetition
max is inclusive
returns an error if min > max
Sourcepub fn exact(n: usize) -> Result<Self, InvalidRepetition>
pub fn exact(n: usize) -> Result<Self, InvalidRepetition>
Creates a new repetition with a fixed number
Sourcepub fn needs_more(&self, nb: usize) -> bool
pub fn needs_more(&self, nb: usize) -> bool
Return true if nb < min
Sourcepub fn map_err<E>(
&self,
nb: usize,
f: impl FnOnce(usize, Option<usize>, usize) -> E,
) -> Result<(), E>
pub fn map_err<E>( &self, nb: usize, f: impl FnOnce(usize, Option<usize>, usize) -> E, ) -> Result<(), E>
Error handling
Calls the provided function f with min, max, nb if nb is outside of the repetition boundaries
Sourcepub fn min_needed(&self, nb: usize) -> usize
pub fn min_needed(&self, nb: usize) -> usize
Returns the minimum number of repetitions needed after nb repetitions
Trait Implementations§
Source§impl Clone for Repetition
impl Clone for Repetition
Source§fn clone(&self) -> Repetition
fn clone(&self) -> Repetition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Repetition
impl Debug for Repetition
Source§impl From<RangeFull> for Repetition
impl From<RangeFull> for Repetition
Source§impl PartialEq for Repetition
impl PartialEq for Repetition
Source§impl TryFrom<RangeInclusive<usize>> for Repetition
impl TryFrom<RangeInclusive<usize>> for Repetition
Source§impl TryFrom<RangeToInclusive<usize>> for Repetition
impl TryFrom<RangeToInclusive<usize>> for Repetition
Source§impl TryFrom<usize> for Repetition
impl TryFrom<usize> for Repetition
impl Copy for Repetition
impl Eq for Repetition
impl StructuralPartialEq for Repetition
Auto Trait Implementations§
impl Freeze for Repetition
impl RefUnwindSafe for Repetition
impl Send for Repetition
impl Sync for Repetition
impl Unpin for Repetition
impl UnwindSafe for Repetition
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more