Skip to main content

IParse

Trait IParse 

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

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

Required Methods§

Source

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

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

Source

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

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".

Implementors§

Source§

impl IParse for &mut TokenIter

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


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()?
        }
    )
}