Struct parser_fuck::combinators::Satisfy
source · pub struct Satisfy<F, I = ()> { /* private fields */ }
Expand description
Check whether it is satisfied
example
let code = "asd123".span();
let x = satisfy(|c: Char| c == 'a');
let r = x.parse(code);
assert_eq!(r, Some(0..1))
Implementations§
Trait Implementations§
source§impl<I, F> Parser<I> for Satisfy<F, I>where
I: TimeTravel,
F: FnMut(I::Item) -> bool,
impl<I, F> Parser<I> for Satisfy<F, I>where I: TimeTravel, F: FnMut(I::Item) -> bool,
type Output = Range<usize>
source§fn map<U, F>(self, f: F) -> Map<Self, I, F>where
Self: Sized,
F: FnMut(Self::Output) -> U,
fn map<U, F>(self, f: F) -> Map<Self, I, F>where Self: Sized, F: FnMut(Self::Output) -> U,
Map a
Parser<Output = T>
to Parser<Output = U>
by applying a function to a contained valuesource§fn and<B>(self, b: B) -> And<Self, B, I>where
Self: Sized,
B: Parser<I>,
fn and<B>(self, b: B) -> And<Self, B, I>where Self: Sized, B: Parser<I>,
Only pass if both subparsers pass
source§fn or<B>(self, b: B) -> Or<Self, B, I>where
Self: Sized,
B: Parser<I, Output = Self::Output>,
fn or<B>(self, b: B) -> Or<Self, B, I>where Self: Sized, B: Parser<I, Output = Self::Output>,
Pass when any subparser passes
source§fn many_min_max(self, min: usize, max: usize) -> Many<Self, I>where
Self: Sized,
fn many_min_max(self, min: usize, max: usize) -> Many<Self, I>where Self: Sized,
{n,m}, >= n && <= m
source§fn and_then<U, F>(self, f: F) -> AndThen<Self, I, F>where
Self: Sized,
U: Parser<I>,
F: FnMut(Self::Output) -> U,
fn and_then<U, F>(self, f: F) -> AndThen<Self, I, F>where Self: Sized, U: Parser<I>, F: FnMut(Self::Output) -> U,
Fail if the subparser fail, otherwise calls f with the new Parser and parse the Parser
source§fn or_else<U, F>(self, f: F) -> OrElse<Self, I, F>where
Self: Sized,
U: Parser<I, Output = Self::Output>,
F: FnMut() -> U,
fn or_else<U, F>(self, f: F) -> OrElse<Self, I, F>where Self: Sized, U: Parser<I, Output = Self::Output>, F: FnMut() -> U,
Pass if subparser pass, otherwise calls f and parse the result Parser
source§fn or_trans<F>(self, no_retry: bool, f: F) -> OrTrans<Self, I, F>where
Self: Sized,
F: FnMut(I, Range<usize>) -> Self::Output,
fn or_trans<F>(self, no_retry: bool, f: F) -> OrTrans<Self, I, F>where Self: Sized, F: FnMut(I, Range<usize>) -> Self::Output,
Pass if subparser pass, otherwise calls f with error point Read more
source§impl<F: PartialEq, I: PartialEq> PartialEq for Satisfy<F, I>
impl<F: PartialEq, I: PartialEq> PartialEq for Satisfy<F, I>
impl<F: Eq, I: Eq> Eq for Satisfy<F, I>
impl<F, I> StructuralEq for Satisfy<F, I>
impl<F, I> StructuralPartialEq for Satisfy<F, I>
Auto Trait Implementations§
impl<F, I = ()> !RefUnwindSafe for Satisfy<F, I>
impl<F, I> Send for Satisfy<F, I>where F: Send, I: Send,
impl<F, I = ()> !Sync for Satisfy<F, I>
impl<F, I> Unpin for Satisfy<F, I>where F: Unpin, I: Unpin,
impl<F, I> UnwindSafe for Satisfy<F, I>where F: UnwindSafe, I: 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