Trait macros_utils::Parse

source ·
pub trait Parse: Sized {
    // Required method
    fn parse(input: &mut MacroStream) -> Result<Self, MacrosError>;
}
Expand description

Parse a MacroStream into a Self.

Example

use macros_utils::{Parse, MacroStream};

#[derive(Debug, Clone)]
struct MyStruct {
    pub a: Token,
    pub b: Token,
}

impl Parse for MyStruct {
    fn parse(input: &mut MacroStream) -> Result<Self, MacrosError> {
        let a = input.pop_or_err()?;
        let b = input.pop_or_err()?;
        Ok(Self { a, b })
    }
}

Required Methods§

source

fn parse(input: &mut MacroStream) -> Result<Self, MacrosError>

Implementors§

source§

impl<T> Parse for Pattern<T>where T: ToOwned<Owned = T> + ParserOutput,