pub struct PredicateTool<P> { /* private fields */ }Expand description
Tool that matches characters which satisfies the provided predicate.
A predicate is a function that accepts char and returns an Option: the None variand will
be interpreted as a nonmatch, whereas the Some(d) variant will be interpreted as a match and the
provided data d is stored in the returned View.
Implementations§
Source§impl<D, P: Fn(char) -> Option<D>> PredicateTool<P>
impl<D, P: Fn(char) -> Option<D>> PredicateTool<P>
Sourcepub const fn new_map(predicate: P) -> Self
pub const fn new_map(predicate: P) -> Self
Create a new PredicateTool from a predicate.
Source§impl<'a> PredicateTool<Box<dyn Fn(char) -> Option<char> + 'a>>
impl<'a> PredicateTool<Box<dyn Fn(char) -> Option<char> + 'a>>
Sourcepub fn new_predicate<F: 'a + Fn(char) -> bool>(f: F) -> Self
pub fn new_predicate<F: 'a + Fn(char) -> bool>(f: F) -> Self
Create a new PredicateTool from a function returning a bool.
A false result is interpreted as a None and a true result is converted to
Some(c) with c is the matched character in the view.
Trait Implementations§
Source§impl<P: Clone> Clone for PredicateTool<P>
impl<P: Clone> Clone for PredicateTool<P>
Source§fn clone(&self) -> PredicateTool<P>
fn clone(&self) -> PredicateTool<P>
Returns a copy 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<P: Debug> Debug for PredicateTool<P>
impl<P: Debug> Debug for PredicateTool<P>
Source§impl<'a, F, D, P: Fn(char) -> Option<D>> ParseTool<'a, F> for PredicateTool<P>
impl<'a, F, D, P: Fn(char) -> Option<D>> ParseTool<'a, F> for PredicateTool<P>
impl<P: Copy> Copy for PredicateTool<P>
Auto Trait Implementations§
impl<P> Freeze for PredicateTool<P>where
P: Freeze,
impl<P> RefUnwindSafe for PredicateTool<P>where
P: RefUnwindSafe,
impl<P> Send for PredicateTool<P>where
P: Send,
impl<P> Sync for PredicateTool<P>where
P: Sync,
impl<P> Unpin for PredicateTool<P>where
P: Unpin,
impl<P> UnwindSafe for PredicateTool<P>where
P: 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