[−][src]Trait markedit::Matcher
A predicate which can be fed a stream of Event
s and tell you whether
they match a desired condition.
Individual Matcher
s may choose to return true
more than once.
Any function which accepts a Event
reference and returns a bool
can be
used as a Matcher
.
fn assert_is_matcher(_: impl Matcher) {} assert_is_matcher(|ev: &Event<'_>| true);
Required methods
fn matches_event(&mut self, event: &Event) -> bool
Evaluate this predicate against an event from an Event
stream.
Provided methods
fn first_match<'src, I, E>(self, events: I) -> Option<usize> where
Self: Sized,
I: IntoIterator<Item = E> + 'src,
E: Borrow<Event<'src>> + 'src,
Self: Sized,
I: IntoIterator<Item = E> + 'src,
E: Borrow<Event<'src>> + 'src,
Find the index of the first Event
which is matched by this
predicate.
fn is_in<'src, I, E>(self, events: I) -> bool where
I: IntoIterator<Item = E> + 'src,
E: Borrow<Event<'src>>,
Self: Sized,
I: IntoIterator<Item = E> + 'src,
E: Borrow<Event<'src>>,
Self: Sized,
Checks whether this Matcher
would match anything in a stream of
Event
s.
Examples
let src = "# Heading\nsome text"; let matcher = markedit::exact_text("some text"); assert!(matcher.is_in(markedit::parse(src)));
fn then_start_of_next_line(self) -> StartOfNextLine<Self> where
Self: Sized,
Self: Sized,
Returns a Matcher
which will wait until self
matches, then return
true
at the start of the next top-level element.
fn fuse(self) -> OneShot<Self> where
Self: Sized,
Self: Sized,
Wraps self
in a Matcher
which will only ever return true
once.
fn falling_edge(self) -> FallingEdge<Self> where
Self: Sized,
Self: Sized,
Get a Matcher
which returns true
when self
goes from true
to
false
.
fn and<M>(self, other: M) -> And<Self, M> where
Self: Sized,
M: Matcher,
Self: Sized,
M: Matcher,
Get a Matcher
which matches when self
and other
both match.
fn by_ref(&mut self) -> Ref<Self> where
Self: Sized,
Self: Sized,
Implementors
impl Matcher for Always
[src]
fn matches_event(&mut self, _event: &Event) -> bool
[src]
impl Matcher for Heading
[src]
fn matches_event(&mut self, event: &Event) -> bool
[src]
impl<'a, M> Matcher for Ref<'a, M> where
M: Matcher,
[src]
M: Matcher,
fn matches_event(&mut self, event: &Event) -> bool
[src]
impl<F> Matcher for F where
F: FnMut(&Event) -> bool,
[src]
F: FnMut(&Event) -> bool,