Struct RepeatTool

Source
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>

Source

pub const fn new_sep(tool: T, sep: SEP, min: usize, max: Option<usize>) -> Self

Create a new RepeatTool with specified separator.

Source

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

Source

pub const fn new_sep_unbounded(tool: T, sep: SEP, min: usize) -> Self

Create a new RepeatTool with specified separator without upper bound

Source

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>

Source

pub const fn new(tool: T, min: usize, max: Option<usize>) -> Self

Create a new RepeatTool without spaces.

§Panics

Panic if max is strictly lesser than min.

Source

pub const fn new_bounds(tool: T, min: usize, max: usize) -> Self

Create a new RepeatTool with specified upper bound

Source

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>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, SEP: Debug> Debug for RepeatTool<T, SEP>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, SEP> ParseTool for RepeatTool<T, SEP>
where T: ParseTool, SEP: ParseTool,

Source§

fn parse(&self, st: &str) -> ToolResult

The main parsing algorithm. Read more
Source§

fn as_dyn(&self) -> &dyn ParseTool
where Self: Sized,

Coerce to dyn trait
Source§

impl<T: Copy, SEP: Copy> Copy for RepeatTool<T, SEP>

Auto Trait Implementations§

§

impl<T, SEP> Freeze for RepeatTool<T, SEP>
where T: Freeze, SEP: Freeze,

§

impl<T, SEP> RefUnwindSafe for RepeatTool<T, SEP>

§

impl<T, SEP> Send for RepeatTool<T, SEP>
where T: Send, SEP: Send,

§

impl<T, SEP> Sync for RepeatTool<T, SEP>
where T: Sync, SEP: Sync,

§

impl<T, SEP> Unpin for RepeatTool<T, SEP>
where T: Unpin, SEP: Unpin,

§

impl<T, SEP> UnwindSafe for RepeatTool<T, SEP>
where T: UnwindSafe, SEP: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.