[go: up one dir, main page]

Regex

Struct Regex 

Source
pub struct Regex<I, E> { /* private fields */ }
Available on crate feature regex only.
Expand description

See regex().

Trait Implementations§

Source§

impl<I, E> Clone for Regex<I, E>

Source§

fn clone(&self) -> Self

Returns a duplicate 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<'src, S, I, E> Parser<'src, I, &'src S, E> for Regex<I, E>
where I: StrInput<'src, Slice = &'src S>, I::Token: Char, S: ?Sized + AsRef<[u8]> + 'src, E: ParserExtra<'src, I>,

Source§

fn parse(&self, input: I) -> ParseResult<O, E::Error>
where I: Input<'src>, E::State: Default, E::Context: Default,

Parse a stream of tokens, yielding an output if possible, and any errors encountered along the way. Read more
Source§

fn parse_with_state( &self, input: I, state: &mut E::State, ) -> ParseResult<O, E::Error>
where I: Input<'src>, E::Context: Default,

Parse a stream of tokens, yielding an output if possible, and any errors encountered along the way. The provided state will be passed on to parsers that expect it, such as map_with. Read more
Source§

fn check(&self, input: I) -> ParseResult<(), E::Error>
where Self: Sized, I: Input<'src>, E::State: Default, E::Context: Default,

Parse a stream of tokens, ignoring any output, and returning any errors encountered along the way. Read more
Source§

fn check_with_state( &self, input: I, state: &mut E::State, ) -> ParseResult<(), E::Error>
where Self: Sized, I: Input<'src>, E::Context: Default,

Parse a stream of tokens, ignoring any output, and returning any errors encountered along the way. Read more
Source§

fn to_slice(self) -> ToSlice<Self, O>
where Self: Sized,

Convert the output of this parser into a slice of the input, based on the current parser’s span. Read more
Source§

fn filter<F: Fn(&O) -> bool>(self, f: F) -> Filter<Self, F>
where Self: Sized,

Filter the output of this parser, accepting only inputs that match the given predicate. Read more
Source§

fn map<U, F: Fn(O) -> U>(self, f: F) -> Map<Self, O, F>
where Self: Sized,

Map the output of this parser to another value. Read more
Source§

fn map_with<U, F: Fn(O, &mut MapExtra<'src, '_, I, E>) -> U>( self, f: F, ) -> MapWith<Self, O, F>
where Self: Sized,

Map the output of this parser to another value, with the opportunity to get extra metadata from the parse like the span or parser state. Read more
Source§

fn map_group<F: Fn<O>>(self, f: F) -> MapGroup<Self, O, F>
where Self: Sized, O: Tuple,

Available on crate feature nightly only.
Map the output of this parser to another value. If the output of this parser isn’t a tuple, use Parser::map. Read more
Source§

fn to_span(self) -> ToSpan<Self, O>
where Self: Sized,

Transform the output of this parser to the pattern’s span. Read more
Source§

fn try_map<U, F: Fn(O, I::Span) -> Result<U, E::Error>>( self, f: F, ) -> TryMap<Self, O, F>
where Self: Sized,

After a successful parse, apply a fallible function to the output. If the function produces an error, treat it as a parsing error. Read more
Source§

fn try_map_with<U, F: Fn(O, &mut MapExtra<'src, '_, I, E>) -> Result<U, E::Error>>( self, f: F, ) -> TryMapWith<Self, O, F>
where Self: Sized,

After a successful parse, apply a fallible function to the output, with the opportunity to get extra metadata. If the function produces an error, treat it as a parsing error. Read more
Source§

fn ignored(self) -> Ignored<Self, O>
where Self: Sized,

Ignore the output of this parser, yielding () as an output instead. Read more
Source§

fn memoized(self) -> Memoized<Self>
where Self: Sized,

Available on crate feature memoization only.
Memoize the parser such that later attempts to parse the same input ‘remember’ the attempt and exit early. Read more
Source§

fn to<U: Clone>(self, to: U) -> To<Self, O, U>
where Self: Sized,

Transform all outputs of this parser to a predetermined value. Read more
Source§

fn labelled<L>(self, label: L) -> Labelled<Self, L>
where Self: Sized, E::Error: LabelError<'src, I, L>,

Label this parser with the given label. Read more
Source§

fn then<U, B: Parser<'src, I, U, E>>(self, other: B) -> Then<Self, B, O, U, E>
where Self: Sized,

Parse one thing and then another thing, yielding a tuple of the two outputs. Read more
Source§

fn ignore_then<U, B: Parser<'src, I, U, E>>( self, other: B, ) -> IgnoreThen<Self, B, O, E>
where Self: Sized,

Parse one thing and then another thing, yielding only the output of the latter. Read more
Source§

fn then_ignore<U, B: Parser<'src, I, U, E>>( self, other: B, ) -> ThenIgnore<Self, B, U, E>
where Self: Sized,

Parse one thing and then another thing, yielding only the output of the former. Read more
Source§

fn nested_in<B: Parser<'src, J, I, F>, J, F>( self, other: B, ) -> NestedIn<Self, B, J, F, O, E>
where Self: Sized, I: 'src, J: Input<'src>, F: ParserExtra<'src, J>,

Parse input as part of a token-tree - using an input generated from within the current input. In other words, this parser will attempt to create a new input stream from within the one it is being run on, and the parser it was called on will be provided this new input. By default, the original parser is expected to consume up to the end of the new stream. To allow only consuming part of the stream, use Parser::lazy to ignore trailing tokens. Read more
Source§

fn ignore_with_ctx<U, P>( self, then: P, ) -> IgnoreWithCtx<Self, P, O, I, Full<E::Error, E::State, O>>
where Self: Sized, O: 'src, P: Parser<'src, I, U, Full<E::Error, E::State, O>>,

Parse one thing and then another thing, creating the second parser from the result of the first. If you do need the context in the output, use Parser::then_with_ctx. Read more
Source§

fn then_with_ctx<U, P>( self, then: P, ) -> ThenWithCtx<Self, P, O, I, Full<E::Error, E::State, O>>
where Self: Sized, O: 'src, P: Parser<'src, I, U, Full<E::Error, E::State, O>>,

Parse one thing and then another thing, creating the second parser from the result of the first. If you don’t need the context in the output, prefer Parser::ignore_with_ctx. Read more
Source§

fn with_ctx<Ctx>(self, ctx: Ctx) -> WithCtx<Self, Ctx>
where Self: Sized, Ctx: 'src + Clone,

Run the previous contextual parser with the provided context. Read more
Source§

fn with_state<State>(self, state: State) -> WithState<Self, State>
where Self: Sized, State: 'src + Clone,

Runs the previous parser with the provided state. Read more
Source§

fn and_is<U, B>(self, other: B) -> AndIs<Self, B, U>
where Self: Sized, B: Parser<'src, I, U, E>,

Applies both parsers to the same position in the input, succeeding only if both succeed. The returned value will be that of the first parser, and the input will be at the end of the first parser if and_is succeeds. Read more
Source§

fn delimited_by<U, V, B, C>( self, start: B, end: C, ) -> DelimitedBy<Self, B, C, U, V>
where Self: Sized, B: Parser<'src, I, U, E>, C: Parser<'src, I, V, E>,

Parse the pattern surrounded by the given delimiters. Read more
Source§

fn padded_by<U, B>(self, padding: B) -> PaddedBy<Self, B, U>
where Self: Sized, B: Parser<'src, I, U, E>,

Parse a pattern, but with an instance of another pattern on either end, yielding the output of the inner. Read more
Source§

fn or<B>(self, other: B) -> Or<Self, B>
where Self: Sized, B: Parser<'src, I, O, E>,

Parse one thing or, on failure, another thing. Read more
Source§

fn or_not(self) -> OrNot<Self>
where Self: Sized,

Attempt to parse something, but only if it exists. Read more
Source§

fn not(self) -> Not<Self, O>
where Self: Sized,

Invert the result of the contained parser, failing if it succeeds and succeeding if it fails. The output of this parser is always (), the unit type. Read more
Source§

fn repeated(self) -> Repeated<Self, O, I, E>
where Self: Sized,

Parse a pattern zero or more times (analog to Regex’s <PAT>*). Read more
Source§

fn separated_by<U, B>(self, separator: B) -> SeparatedBy<Self, B, O, U, I, E>
where Self: Sized, B: Parser<'src, I, U, E>,

Parse a pattern, separated by another, any number of times. Read more
Source§

fn foldl<B, F, OB>(self, other: B, f: F) -> Foldl<F, Self, B, OB, E>
where F: Fn(O, OB) -> O, B: IterParser<'src, I, OB, E>, Self: Sized,

Left-fold the output of the parser into a single value. Read more
Source§

fn foldl_with<B, F, OB>(self, other: B, f: F) -> FoldlWith<F, Self, B, OB, E>
where F: Fn(O, OB, &mut MapExtra<'src, '_, I, E>) -> O, B: IterParser<'src, I, OB, E>, Self: Sized,

Left-fold the output of the parser into a single value, making use of the parser’s state when doing so. Read more
Source§

fn rewind(self) -> Rewind<Self>
where Self: Sized,

Parse a pattern. Afterwards, the input stream will be rewound to its original state, as if parsing had not occurred. Read more
Source§

fn lazy(self) -> Lazy<'src, Self, I, E>
where Self: Sized, I: ValueInput<'src>,

Make the parser lazy, such that it parses as much of the input as it can finishes successfully, leaving the trailing input untouched. Read more
Source§

fn padded(self) -> Padded<Self>
where Self: Sized, I: Input<'src>, I::Token: Char,

Parse a pattern, ignoring any amount of whitespace both before and after the pattern. Read more
Source§

fn recover_with<S: Strategy<'src, I, O, E>>( self, strategy: S, ) -> RecoverWith<Self, S>
where Self: Sized,

Apply a fallback recovery strategy to this parser should it fail. Read more
Source§

fn map_err<F>(self, f: F) -> MapErr<Self, F>
where Self: Sized, F: Fn(E::Error) -> E::Error,

Map the primary error of this parser to another value. Read more
Source§

fn map_err_with_state<F>(self, f: F) -> MapErrWithState<Self, F>
where Self: Sized, F: Fn(E::Error, I::Span, &mut E::State) -> E::Error,

Map the primary error of this parser to another value, making use of the parser state. Read more
Source§

fn validate<U, F>(self, f: F) -> Validate<Self, O, F>
where Self: Sized, F: Fn(O, &mut MapExtra<'src, '_, I, E>, &mut Emitter<E::Error>) -> U,

Validate an output, producing non-terminal errors if it does not fulfill certain criteria. The errors will not immediately halt parsing on this path, but instead it will continue, potentially emitting one or more other errors, only failing after the pattern has otherwise successfully, or emitted another terminal error. Read more
Source§

fn from_str<U>(self) -> Map<Self, O, fn(O) -> Result<U, U::Err>>
where Self: Sized, U: FromStr, O: AsRef<str>,

Attempt to convert the output of this parser into something else using Rust’s FromStr trait. Read more
Source§

fn unwrapped(self) -> Unwrapped<Self, O>
where Self: Sized,

For parsers that produce a Result as their output, unwrap the result (panicking if an Err is encountered). Read more
Source§

fn into_iter(self) -> IntoIter<Self, O>
where Self: Sized, O: IntoIterator,

Turn this Parser into an IterParser if its output type implements IntoIterator. Read more
Source§

fn boxed<'b>(self) -> Boxed<'src, 'b, I, O, E>
where Self: Sized + 'src + 'b,

Box the parser, yielding a parser that performs parsing through dynamic dispatch. Read more
Source§

fn simplify(self) -> impl Parser<'src, I, O, E>
where Self: Sized + 'src,

Available on crate feature nightly only.
Simplify the type of the parser using Rust’s impl Trait syntax. Read more
Source§

fn pratt<Ops>(self, ops: Ops) -> Pratt<Self, Ops>
where Self: Sized,

Available on crate feature pratt only.
Use Pratt parsing to ergonomically parse this pattern separated by prefix, postfix, and infix operators of various associativites and precedence. Read more

Auto Trait Implementations§

§

impl<I, E> Freeze for Regex<I, E>

§

impl<I, E> RefUnwindSafe for Regex<I, E>

§

impl<I, E> Send for Regex<I, E>

§

impl<I, E> Sync for Regex<I, E>

§

impl<I, E> Unpin for Regex<I, E>

§

impl<I, E> UnwindSafe for Regex<I, E>

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

Source§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
Source§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
Source§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
Source§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
Source§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a MaybeRef.
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.
Source§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,