IParse

Trait IParse 

Source
pub trait IParse: Sealed {
    // Required methods
    fn parse<T>(self) -> Result<T, Error>
       where T: Parse;
    fn parse_all<T>(self) -> Result<T, Error>
       where T: Parse;
}
Expand description

Extension trait for TokenIter that calls Parse::parse().

Required Methods§

Source

fn parse<T>(self) -> Result<T, Error>
where T: Parse,

Parse a value from the iterator. This is a convenience method that calls Parse::parse().

Source

fn parse_all<T>(self) -> Result<T, Error>
where T: Parse,

Parse a value from the iterator. This is a convenience method that calls Parse::parse_all().

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 IParse for &mut ShadowCountedIter<'_, <TokenStream as IntoIterator>::IntoIter>

Implements IParse for [&mut TokenIter]. This API is more convenient in cases where the compiler can infer types because no turbofish notations are required.

§Example

use unsynn::*;

struct MyStruct {
    number: LiteralInteger,
    name:   Ident,
}

fn example() -> Result<MyStruct> {
    let mut input = " 1234 name ".to_token_iter();
    Ok(
        MyStruct {
            // types are inferred here
            number: input.parse()?,
            name: input.parse()?
        }
    )
}
Source§

fn parse<T>(self) -> Result<T, Error>
where T: Parse,

Source§

fn parse_all<T>(self) -> Result<T, Error>
where T: Parse,

Implementors§