nom_supreme::parser_ext

Struct FromStrCutParser

Source
pub struct FromStrCutParser<P, T> { /* private fields */ }
Expand description

Parser which parses something via FromStr, using a subparser as a recognizer for the string to pass to from_str. Returns Err::Failure if the FromStr parse fails.

Trait Implementations§

Source§

impl<P: Clone, T: Clone> Clone for FromStrCutParser<P, T>

Source§

fn clone(&self) -> FromStrCutParser<P, T>

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<P: Debug, T: Debug> Debug for FromStrCutParser<P, T>

Source§

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

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

impl<'a, I, T, E, P> Parser<I, T, E> for FromStrCutParser<P, T>
where P: Parser<I, &'a str, E>, I: Clone, T: FromStr, E: FromExternalError<I, T::Err>,

Source§

fn parse(&mut self, input: I) -> IResult<I, T, E>

A parser takes in input type, and returns a Result containing either the remaining input and the output value, or an error
Source§

fn map<G, O2>(self, g: G) -> Map<Self, G, O>
where G: Fn(O) -> O2, Self: Sized,

Maps a function over the result of a parser
Source§

fn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O>
where G: FnMut(O) -> H, H: Parser<I, O2, E>, Self: Sized,

Creates a second parser from the output of the first one, then apply over the rest of the input
Source§

fn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O>
where G: Parser<O, O2, E>, Self: Sized,

Applies a second parser over the output of the first one
Source§

fn and<G, O2>(self, g: G) -> And<Self, G>
where G: Parser<I, O2, E>, Self: Sized,

Applies a second parser after the first one, return their results as a tuple
Source§

fn or<G>(self, g: G) -> Or<Self, G>
where G: Parser<I, O, E>, Self: Sized,

Applies a second parser over the input if the first one failed
Source§

fn into<O2, E2>(self) -> Into<Self, O, O2, E, E2>
where O2: From<O>, E2: From<E>, Self: Sized,

automatically converts the parser’s output and error values to another type, as long as they implement the From trait
Source§

impl<P: Copy, T: Copy> Copy for FromStrCutParser<P, T>

Auto Trait Implementations§

§

impl<P, T> Freeze for FromStrCutParser<P, T>
where P: Freeze,

§

impl<P, T> RefUnwindSafe for FromStrCutParser<P, T>

§

impl<P, T> Send for FromStrCutParser<P, T>
where P: Send, T: Send,

§

impl<P, T> Sync for FromStrCutParser<P, T>
where P: Sync, T: Sync,

§

impl<P, T> Unpin for FromStrCutParser<P, T>
where P: Unpin, T: Unpin,

§

impl<P, T> UnwindSafe for FromStrCutParser<P, T>
where P: UnwindSafe, T: 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<I, T> ExtractContext<I, ()> for T

Source§

fn extract_context(self, _original_input: I)

Given the context attached to a nom error, and given the original input to the nom parser, extract more the useful context information. 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<I, O, E, P> ParserExt<I, O, E> for P
where P: Parser<I, O, E>,

Source§

fn by_ref(&mut self) -> RefParser<'_, Self>

Borrow a parser. This allows building parser combinators while still retaining ownership of the original parser. This is necessary because impl<T: Parser> Parser for &mut T is impossible due to conflicts with impl<T: FnMut> Parser for T. Read more
Source§

fn all_consuming(self) -> AllConsuming<Self>
where I: InputLength, E: ParseError<I>,

Create a parser that must consume all of the input, or else return an error. Read more
Source§

fn complete(self) -> Complete<Self>
where I: Clone, E: ParseError<I>,

Create a parser that transforms Incomplete into Error. Read more
Source§

fn cut(self) -> Cut<Self>

Create a parser that transforms Error into Failure. This will end the parse immediately, even if there are other branches that could occur. Read more
Source§

fn map_res<F, O2, E2>(self, func: F) -> MapRes<Self, F, O, E2>
where F: FnMut(O) -> Result<O2, E2>, E: FromExternalError<I, E2>, I: Clone,

Create a parser that applies a mapping function func to the output of the subparser. Any errors from func will be transformed into parse errors via FromExternalError. Read more
Source§

fn map_res_cut<F, O2, E2>(self, func: F) -> MapResCut<Self, F, O, E2>
where F: FnMut(O) -> Result<O2, E2>, E: FromExternalError<I, E2>, I: Clone,

Create a parser that applies a mapping function func to the output of the subparser. Any errors from func will be transformed into parse failures via FromExternalError. This will end the parse immediately, even if there are other branches that could occur. Read more
Source§

fn opt(self) -> Optional<Self>
where I: Clone,

Make this parser optional; if it fails to parse, instead it returns None with the input in the original position. Read more
Source§

fn recognize(self) -> Recognize<Self, O>
where I: Clone + Slice<RangeTo<usize>> + Offset,

Replace this parser’s output with the entire input that was consumed by the parser. Read more
Source§

fn with_recognized(self) -> WithRecognized<Self>
where I: Clone + Slice<RangeTo<usize>> + Offset,

Return the parsed value, but also return the entire input that was consumed by the parse Read more
Source§

fn value<T: Clone>(self, value: T) -> Value<T, Self, O>

Replace this parser’s output with a clone of value every time it finishes successfully. Read more
Source§

fn verify<F>(self, verifier: F) -> Verify<Self, F>
where F: Fn(&O) -> bool, I: Clone, E: ParseError<I>,

Require the output of this parser to pass a verifier function, or else return a parse error. Read more
Source§

fn context<C>(self, context: C) -> Context<Self, C>
where E: ContextError<I, C>, I: Clone, C: Clone,

Add some context to the parser. This context will be added to any errors that are returned from the parser via ContextError. Read more
Source§

fn terminated<F, O2>(self, terminator: F) -> Terminated<Self, F, O2>
where F: Parser<I, O2, E>,

Add a terminator parser. The terminator will run after this parser, returning any errors, but its output will otherwise be discarded. Read more
Source§

fn precedes<F, O2>(self, successor: F) -> Preceded<F, Self, O>
where F: Parser<I, O2, E>,

Make this parser precede another one. The successor parser will run after this one succeeds, and the successor’s output will be returned. Read more
Source§

fn preceded_by<F, O2>(self, prefix: F) -> Preceded<Self, F, O2>
where F: Parser<I, O2, E>,

Make this parser preceded by another one. The prefix will run first, and if it succeeds, its output will be discard and this parser will be run. Read more
Source§

fn opt_precedes<F, O2>(self, successor: F) -> OptionalPreceded<Self, F>
where E: ParseError<I>, I: Clone, F: Parser<I, O2, E>,

Make this parser optionally precede by another one. self will run first, and then the successor will run even if self returns an error. Both outputs will be returned. This is functionally equivalent to self.opt().and(successor), but it has the added benefit that if both parsers return an error, the error from the prefix will be retained, rather than discarded. Read more
Source§

fn opt_preceded_by<F, O2>(self, prefix: F) -> OptionalPreceded<F, Self>
where E: ParseError<I>, I: Clone, F: Parser<I, O2, E>,

Make this parser optionally preceded by another one. The prefix will run first, and then this parser will run even if the prefix returned an error. Both outputs will be returned. This is functionally equivalent to prefix.opt().and(self), but it has the added benefit that if both parsers return an error, the error from the prefix will be retained, rather than discarded. Read more
Source§

fn delimited_by<D, O2>(self, delimiter: D) -> Delimited<Self, D, O2>
where D: Parser<I, O2, E>,

Make this parser delimited, requiring a delimiter as both a prefix and a suffix. The output of the delimiters is discarded. Read more
Source§

fn peek(self) -> Peek<Self>
where I: Clone,

Make this parser peeking: it runs normally but consumes no input. Read more
Source§

fn not(self) -> Not<Self, O>
where I: Clone, E: ParseError<I>,

Make this parser a negative lookahead: it will succeed if the subparser fails, and fail if the subparser succeeds. Read more
Source§

fn parse_from_str<'a, T>(self) -> FromStrParser<Self, T>
where Self: Parser<I, &'a str, E>, I: Clone, T: FromStr, E: FromExternalError<I, T::Err>,

Create a parser that parses something via FromStr, using this parser as a recognizer for the string to pass to from_str. Read more
Source§

fn parse_from_str_cut<'a, T>(self) -> FromStrCutParser<Self, T>
where Self: Parser<I, &'a str, E>, I: Clone, T: FromStr, E: FromExternalError<I, T::Err>,

Create a parser that parses something via FromStr, using this parser as a recognizer for the string to pass to from_str. This parser transforms any errors from FromStr into Err::Failure, which will end the overall parse immediately, even if there are other branches that could be tried. Read more
Source§

fn array(self) -> ArrayParser<Self>

Create a parser that parses a fixed-size array by running this parser in a loop. Read more
Source§

fn separated_array<F, O2>( self, separator: F, ) -> SeparatedArrayParser<Self, F, O2>
where F: Parser<I, O2, E>,

Create a parser that parses a fixed-size array by running this parser in a loop, parsing a separator in between each element. Read more
Source§

impl<I> RecreateContext<I> for I

Source§

fn recreate_context(_original_input: I, tail: I) -> I

Given the original input, as well as the context reported by nom, recreate a context in the original string where the error occurred. Read more
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.