macros_utils/
parse.rs

1use crate::{MacroStream, MacrosError};
2
3/// Parse a `MacroStream` into a `Self`.
4///
5/// # Example
6/// ```rs
7/// use macros_utils::{Parse, MacroStream};
8///
9/// #[derive(Debug, Clone)]
10/// struct MyStruct {
11///     pub a: Token,
12///     pub b: Token,
13/// }
14///
15/// impl Parse for MyStruct {
16///     fn parse(input: &mut MacroStream) -> Result<Self, MacrosError> {
17///         let a = input.pop_or_err()?;
18///         let b = input.pop_or_err()?;
19///         Ok(Self { a, b })
20///     }
21/// }
22pub trait Parse: Sized {
23    fn parse(input: &mut MacroStream) -> Result<Self, MacrosError>;
24}