pub struct RepeatTool<T, SEP> { /* private fields */ }Expand description
Tool that matches repetitions with separator requiring a minimum number of repetitions.
let lt = minparser::view::ViewFile::new_default("a a a a b");
assert_eq!(lt.match_tool_string(minparser::tools::RepeatTool::new_sep_bounds('a', ' ', 0, 3))
.unwrap().1, "a a a");
assert_eq!(lt.match_tool_string(minparser::tools::RepeatTool::new_sep_bounds('a', ' ', 2, 3))
.unwrap().1, "a a a");
assert_eq!(lt.match_tool_string(minparser::tools::RepeatTool::new_sep_unbounded('a', ' ', 0))
.unwrap().1, "a a a a");
assert_eq!(lt.match_tool_string(minparser::tools::RepeatTool::new_sep_unbounded('a', ' ', 2))
.unwrap().1, "a a a a");
assert!(lt.match_tool_string(minparser::tools::RepeatTool::new_sep_unbounded('a', ' ', 5))
.is_err());
assert!(lt.match_tool_string(minparser::tools::RepeatTool::new_sep_bounds('a', ' ', 2, 1))
.is_err());Implementations§
Source§impl<T, SEP> RepeatTool<T, SEP>
impl<T, SEP> RepeatTool<T, SEP>
Sourcepub const fn new_sep(tool: T, sep: SEP, min: usize, max: Option<usize>) -> Self
pub const fn new_sep(tool: T, sep: SEP, min: usize, max: Option<usize>) -> Self
Create a new RepeatTool with specified separator.
Sourcepub const fn new_sep_bounds(tool: T, sep: SEP, min: usize, max: usize) -> Self
pub const fn new_sep_bounds(tool: T, sep: SEP, min: usize, max: usize) -> Self
Create a new RepeatTool with specified separator and upper bound
Sourcepub const fn new_sep_unbounded(tool: T, sep: SEP, min: usize) -> Self
pub const fn new_sep_unbounded(tool: T, sep: SEP, min: usize) -> Self
Create a new RepeatTool with specified separator without upper bound
Sourcepub const fn new_any_one(tool: T, sep: SEP) -> Self
pub const fn new_any_one(tool: T, sep: SEP) -> Self
Create a new RepeatTool that matches at least one occurrence
Source§impl<T> RepeatTool<T, TrueParser>
impl<T> RepeatTool<T, TrueParser>
Sourcepub const fn new_bounds(tool: T, min: usize, max: usize) -> Self
pub const fn new_bounds(tool: T, min: usize, max: usize) -> Self
Create a new RepeatTool with specified upper bound
Sourcepub const fn new_unbounded(tool: T, min: usize) -> Self
pub const fn new_unbounded(tool: T, min: usize) -> Self
Create a new RepeatTool without upper bound
Trait Implementations§
Source§impl<T: Clone, SEP: Clone> Clone for RepeatTool<T, SEP>
impl<T: Clone, SEP: Clone> Clone for RepeatTool<T, SEP>
Source§fn clone(&self) -> RepeatTool<T, SEP>
fn clone(&self) -> RepeatTool<T, SEP>
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<T, SEP> ParseTool for RepeatTool<T, SEP>
impl<T, SEP> ParseTool for RepeatTool<T, SEP>
impl<T: Copy, SEP: Copy> Copy for RepeatTool<T, SEP>
Auto Trait Implementations§
impl<T, SEP> Freeze for RepeatTool<T, SEP>
impl<T, SEP> RefUnwindSafe for RepeatTool<T, SEP>where
T: RefUnwindSafe,
SEP: RefUnwindSafe,
impl<T, SEP> Send for RepeatTool<T, SEP>
impl<T, SEP> Sync for RepeatTool<T, SEP>
impl<T, SEP> Unpin for RepeatTool<T, SEP>
impl<T, SEP> UnwindSafe for RepeatTool<T, SEP>where
T: UnwindSafe,
SEP: 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