pub trait AttributeOptions: Sized {
    // Required method
    fn from_iter(
        span: Span,
        attributes: impl IntoIterator<Item = Attribute>
    ) -> Result<Self, Error>;

    // Provided methods
    fn from_attr(attribute: Attribute) -> Result<Self, Error> { ... }
    fn from_iter_named(
        attr_name: &str,
        span: Span,
        attributes: impl IntoIterator<Item = Attribute>
    ) -> Result<Self, Error> { ... }
    fn from_stream(input: &ParseBuffer<'_>) -> Result<Self, Error> { ... }
}
Available on crate feature attr_parse only.
Expand description

Options derivable from Attributes.

Required Methods§

source

fn from_iter( span: Span, attributes: impl IntoIterator<Item = Attribute> ) -> Result<Self, Error>

Parse and construct from an iterator of attributes

The span is what will be used for printing errors if nothing more appropriate is available. It’s likely the field or struct you’re parsing.

Provided Methods§

source

fn from_attr(attribute: Attribute) -> Result<Self, Error>

Parse and construct from an attribute

source

fn from_iter_named( attr_name: &str, span: Span, attributes: impl IntoIterator<Item = Attribute> ) -> Result<Self, Error>

Shorthand for filtering attributes by name and passing them on to from_iter.

The span is what will be used for printing errors if nothing more appropriate is available. It’s likely the field or struct you’re parsing.

source

fn from_stream(input: &ParseBuffer<'_>) -> Result<Self, Error>

Parse a stream containing options: opt1(val1), opt2(val2)

Object Safety§

This trait is not object safe.

Implementors§