Struct StopOn

Source
pub struct StopOn<S: AsRef<str> = &'static str, F: Fn(char) -> bool + 'static = fn(_: char) -> bool> { /* private fields */ }
Expand description

A parser that parses until a literal is found.

Implementations§

Source§

impl<S: AsRef<str>> StopOn<S>

Source

pub fn new(literal: S) -> Self

Create a new literal parser.

Source§

impl<S: AsRef<str>, F: Fn(char) -> bool + 'static> StopOn<S, F>

Source

pub fn filter_characters(self, character_filter: F) -> StopOn<S, F>

Only allow characters that pass the filter.

Source

pub fn literal(&self) -> &str

Get the literal that this parser stops on.

Trait Implementations§

Source§

impl<S: Clone + AsRef<str>, F: Clone + Fn(char) -> bool + 'static> Clone for StopOn<S, F>

Source§

fn clone(&self) -> StopOn<S, F>

Returns a copy 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<S: AsRef<str>> CreateParserState for StopOn<S>

Source§

fn create_parser_state(&self) -> <Self as Parser>::PartialState

Create the default state of the parser.
Source§

impl<S: Debug + AsRef<str>, F: Debug + Fn(char) -> bool + 'static> Debug for StopOn<S, F>

Source§

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

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

impl<S: AsRef<str>> From<S> for StopOn<S>

Source§

fn from(literal: S) -> Self

Converts to this type from the input type.
Source§

impl<S: AsRef<str>, F: Fn(char) -> bool + 'static> Parser for StopOn<S, F>

Source§

type Output = String

The output of the parser.
Source§

type PartialState = StopOnOffset

The state of the parser.
Source§

fn parse<'a>( &self, state: &StopOnOffset, input: &'a [u8], ) -> ParseResult<ParseStatus<'a, Self::PartialState, Self::Output>>

Parse the given input.
Source§

impl<S: PartialEq + AsRef<str>, F: PartialEq + Fn(char) -> bool + 'static> PartialEq for StopOn<S, F>

Source§

fn eq(&self, other: &StopOn<S, F>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Copy + AsRef<str>, F: Copy + Fn(char) -> bool + 'static> Copy for StopOn<S, F>

Source§

impl<S: Eq + AsRef<str>, F: Eq + Fn(char) -> bool + 'static> Eq for StopOn<S, F>

Source§

impl<S: AsRef<str>, F: Fn(char) -> bool + 'static> StructuralPartialEq for StopOn<S, F>

Auto Trait Implementations§

§

impl<S, F> Freeze for StopOn<S, F>
where S: Freeze, F: Freeze,

§

impl<S, F> RefUnwindSafe for StopOn<S, F>

§

impl<S, F> Send for StopOn<S, F>
where S: Send, F: Send,

§

impl<S, F> Sync for StopOn<S, F>
where S: Sync, F: Sync,

§

impl<S, F> Unpin for StopOn<S, F>
where S: Unpin, F: Unpin,

§

impl<S, F> UnwindSafe for StopOn<S, F>
where S: UnwindSafe, F: 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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<P> ParserExt for P
where P: Parser,

Source§

fn otherwise<V: Parser>(self, other: V) -> ChoiceParser<Self, V>
where Self: Sized,

Parse this parser, or another other parser.
Source§

fn or<V: Parser<Output = Self::Output>>( self, other: V, ) -> MapOutputParser<ChoiceParser<Self, V>, Self::Output>
where Self: Sized,

Parse this parser, or another other parser with the same type
Source§

fn then<V: Parser>(self, other: V) -> SequenceParser<Self, V>
where Self: Sized,

Parse this parser, then the other parser.
Source§

fn then_lazy<V, F>(self, other: F) -> ThenLazy<Self, F>
where Self: Sized, V: CreateParserState, F: Fn(&Self::Output) -> V,

Parse this parser, then the other parser that is created base on the output of this parser.
Source§

fn ignore_output_then<V: CreateParserState>( self, other: V, ) -> MapOutputParser<SequenceParser<Self, V>, <V as Parser>::Output>
where Self: Sized,

Parse this parser, then the other parser while ignoring the current parser’s output.
Source§

fn then_ignore_output<V: CreateParserState>( self, other: V, ) -> MapOutputParser<SequenceParser<Self, V>, <Self as Parser>::Output>
where Self: Sized,

Parse this parser, then the other parser while ignoring the output of the other parser.
Source§

fn then_literal( self, literal: impl Into<Cow<'static, str>>, ) -> MapOutputParser<SequenceParser<Self, LiteralParser>, <Self as Parser>::Output>
where Self: Sized,

Parse this parser, then a literal. This is equivalent to .then_ignore_output(LiteralParser::new(literal)).
Source§

fn repeat(self, length_range: RangeInclusive<usize>) -> RepeatParser<Self>
where Self: Sized,

Repeat this parser a number of times.
Source§

fn map_output<F, O>(self, f: F) -> MapOutputParser<Self, O, F>
where Self: Sized, F: Fn(Self::Output) -> O,

Map the output of this parser.
Source§

fn boxed(self) -> ArcParser<Self::Output>
where Self: CreateParserState + Sized + Send + Sync + 'static, Self::Output: Send + Sync + 'static, Self::PartialState: Send + Sync + 'static,

Get a boxed version of this parser.
Source§

fn with_initial_state<F: Fn() -> Self::PartialState + Clone>( self, initial_state: F, ) -> WithInitialState<Self, F>
where Self: Sized,

Create a new parser with a different initial state
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.