Skip to main content

Parse

Trait Parse 

Source
pub trait Parse: Sized {
    type Error: ParseError;

    // Required method
    fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>;

    // Provided method
    fn name() -> Option<impl Display> { ... }
}
Expand description

Parsable types

Required Associated Types§

Source

type Error: ParseError

Error type

Required Methods§

Source

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Parses this type from input, mutating it in-place.

Provided Methods§

Source

fn name() -> Option<impl Display>

A name for this type.

This is mostly used in error reporting and should be a lower case name, with a / an prefixed. Used for example in the following way: expected {name}, found {other_name}.

If this returns None, no extra error is displayed when parsing the type. This is useful for containers that usually don’t want to expose themselves

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Parse for Comment

Source§

type Error = CommentError

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl Parse for !

Source§

type Error = NeverError

Source§

fn parse_from(_parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl Parse for ()

Source§

type Error = !

Source§

fn parse_from(_parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl Parse for BlockComment

Source§

type Error = BlockCommentError

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl Parse for LineComment

Source§

type Error = LineCommentError

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl Parse for PureWhitespace

Source§

type Error = !

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl Parse for Whitespace

Source§

type Error = WhitespaceError

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl Parse for WhitespaceInner

Source§

type Error = WhitespaceInnerError

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl<T0: Parse> Parse for (T0,)

Source§

type Error = Tuple1Error<T0>

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl<T0: Parse, T1: Parse> Parse for (T0, T1)

Source§

type Error = Tuple2Error<T0, T1>

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl<T0: Parse, T1: Parse, T2: Parse> Parse for (T0, T1, T2)

Source§

type Error = Tuple3Error<T0, T1, T2>

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl<T0: Parse, T1: Parse, T2: Parse, T3: Parse> Parse for (T0, T1, T2, T3)

Source§

type Error = Tuple4Error<T0, T1, T2, T3>

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl<T> Parse for Option<T>
where T: Parse,

Source§

type Error = <T as Parse>::Error

Source§

fn name() -> Option<impl Display>

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl<T> Parse for Box<T>
where T: Parse,

Source§

type Error = <T as Parse>::Error

Source§

fn name() -> Option<impl Display>

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl<T> Parse for Vec<T>
where T: Parse,

Source§

type Error = <T as Parse>::Error

Source§

fn name() -> Option<impl Display>

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl<T> Parse for PhantomData<T>

Source§

type Error = !

Source§

fn parse_from(_parser: &mut Parser) -> Result<Self, Self::Error>

Source§

impl<T: ArenaData + Parse> Parse for ArenaIdx<T>

Source§

type Error = <T as Parse>::Error

Source§

fn name() -> Option<impl Display>

Source§

fn parse_from(parser: &mut Parser) -> Result<Self, Self::Error>

Implementors§

Source§

impl<T, R> Parse for RecursiveWrapper<T, R>

Source§

type Error = RecursiveWrapperError<R>