1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::{MacroStream, MacrosError};

/// Parse a `MacroStream` into a `Self`.
///
/// # Example
/// ```rs
/// 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 })
///     }
/// }
pub trait Parse: Sized {
    fn parse(input: &mut MacroStream) -> Result<Self, MacrosError>;
}