Skip to main content

Prefix

Struct Prefix 

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

Sequence of two grammars, Deref-ing to the second.

Fields§

§prefixed: T

The prefixed value.

Implementations§

Source§

impl<P, T> Prefix<P, T>

Source

pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Prefix<P, U>

Apply f to the prefixed value, keeping prefix unchanged.

Source§

impl<P, T, E> Prefix<P, Result<T, E>>

Source

pub fn transpose(self) -> Result<Prefix<P, T>, E>

Swap Prefix<P, Result<T, E>> for Result<Prefix<P, T>, E>.

Trait Implementations§

Source§

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

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<P: Debug, T: Debug> Debug for Prefix<P, T>

Source§

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

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

impl<P, T> Deref for Prefix<P, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<P: Eq, T: Eq> Eq for Prefix<P, T>

Source§

impl<P: Grammar, T: Grammar> Grammar for Prefix<P, T>

Source§

type First = <<OptionalFirst<EmptyByteSet> as First>::Concat<P> as First>::Concat<T>

The set of bytes (and whether empty input is valid) this grammar could start with.
Source§

fn parse_at(input: &str, pos: usize, state: State<'_>) -> Option<(Self, usize)>

Attempt to parse Self starting at pos, returning the value and the position just past it, or None on failure.
Source§

fn scan_at(input: &str, pos: usize, state: State<'_>) -> Option<usize>

Like parse_at, but only checks well-formedness and returns the end position.
Source§

fn print_to(&self, buf: &mut String)

Serialize self back to text, appending to buf.
Source§

fn to_bnf() -> Expr

Describe this grammar as a BNF/EBNF expression, for use in a referencing rule’s own definition.
Source§

fn fail_at(pos: usize, state: State<'_>) -> bool

Record what this grammar would have expected at pos, without attempting to actually parse — used when a caller already knows (e.g. via First) that this alternative cannot match here, but still wants it traced. Read more
Source§

fn parse(input: &str) -> Result<Self, Error>

Parse the entire input as Self, failing if any input is left unconsumed.
Source§

fn parse_prefix(input: &str) -> Result<(Self, usize), Error>

Like parse, but doesn’t require consuming all of input — returns the byte position just past the match, leaving any remaining input unexamined.
Source§

fn scan(input: &str) -> Result<(), Error>

Like parse, but only checks that input is well-formed and discards the parsed value.
Source§

fn scan_prefix(input: &str) -> Result<usize, Error>

Like scan, but doesn’t require consuming all of input — returns the byte position just past the match, leaving any remaining input unexamined.
Source§

fn print(&self) -> String

Serialize self to a new String; see print_to.
Source§

impl<P: Grammar, T: Grammar> GrammarRule for Prefix<P, T>

Source§

const NAME: &'static str = "Prefix"

The rule’s name in BNF output; defaults to the type name.
Source§

fn to_bnf_def() -> Expr

This rule’s own definition, as opposed to to_bnf, which is how other rules refer to it.
Source§

fn bnf_rule() -> String

Format this rule as a complete BNF line: NAME = <definition> ..
Source§

impl<P, T> IntoInner<T> for Prefix<P, T>

Source§

fn into_inner(self) -> T

Consume self, discarding whatever structure wrapped T.
Source§

impl<P: PartialEq, T: PartialEq> PartialEq for Prefix<P, T>

Source§

fn eq(&self, other: &Prefix<P, T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<P: PartialEq, T: PartialEq> StructuralPartialEq for Prefix<P, T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<P, T> UnsafeUnpin for Prefix<P, T>
where P: UnsafeUnpin, T: UnsafeUnpin,

§

impl<P, T> UnwindSafe for Prefix<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, 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.