Trait bparse::Repetition
source · pub trait Repetition {
// Required methods
fn lower_bound(&self) -> usize;
fn upper_bound(&self) -> Option<usize>;
}Expand description
Trait used to specify start and end bounds for pattern repetitions
Unlike the standard library’s std::ops::RangeBounds,
- this trait cannot express an unbounded lower bound
- this trait’s bounds are always inclusive
Examples
use bparse::Repetition;
assert_eq!(3.lower_bound(), 3);
assert_eq!(3.upper_bound(), Some(3));
assert_eq!((2..=4).lower_bound(), 2);
assert_eq!((2..=4).upper_bound(), Some(4));
assert_eq!((..=10).lower_bound(), 0);
assert_eq!((..=10).upper_bound(), Some(10));
assert_eq!((3..).lower_bound(), 3);
assert_eq!((3..).upper_bound(), None);Required Methods§
sourcefn lower_bound(&self) -> usize
fn lower_bound(&self) -> usize
The minimum amount of times a pattern should repeat
sourcefn upper_bound(&self) -> Option<usize>
fn upper_bound(&self) -> Option<usize>
The maxiumum amount of times a pattern should repeat, possibly unbounded.