ParseMultiple

Trait ParseMultiple 

Source
pub(crate) trait ParseMultiple:
    Parse
    + Sized
    + 'static {
    // Provided methods
    fn parse_attr_with<P: Parser>(attr: &Attribute, parser: &P) -> Result<Self> { ... }
    fn merge_attrs(
        _prev: Spanning<Self>,
        new: Spanning<Self>,
        name: &Ident,
    ) -> Result<Spanning<Self>> { ... }
    fn merge_opt_attrs(
        prev: Option<Spanning<Self>>,
        new: Option<Spanning<Self>>,
        name: &Ident,
    ) -> Result<Option<Spanning<Self>>> { ... }
    fn parse_attrs_with<P: Parser>(
        attrs: impl AsRef<[Attribute]>,
        name: &Ident,
        parser: &P,
    ) -> Result<Option<Spanning<Self>>> { ... }
    fn parse_attrs(
        attrs: impl AsRef<[Attribute]>,
        name: &Ident,
    ) -> Result<Option<Spanning<Self>>> { ... }
}
Expand description

Parsing of a typed attribute from multiple syn::Attributes.

Provided Methods§

Source

fn parse_attr_with<P: Parser>(attr: &Attribute, parser: &P) -> Result<Self>

Parses this attribute from the provided single syn::Attribute with the provided Parser.

Required, because with Parse we only able to parse inner attribute tokens, which doesn’t work for attributes with empty arguments, like #[attr].

Override this method if the default syn::Attribute::parse_args_with() is not enough.

Source

fn merge_attrs( _prev: Spanning<Self>, new: Spanning<Self>, name: &Ident, ) -> Result<Spanning<Self>>

Merges multiple values of this attribute into a single one.

Default implementation only errors, disallowing multiple values of the same attribute.

Source

fn merge_opt_attrs( prev: Option<Spanning<Self>>, new: Option<Spanning<Self>>, name: &Ident, ) -> Result<Option<Spanning<Self>>>

Merges multiple Optional values of this attribute into a single one.

Default implementation uses ParseMultiple::merge_attrs() when both prev and new are Some.

Source

fn parse_attrs_with<P: Parser>( attrs: impl AsRef<[Attribute]>, name: &Ident, parser: &P, ) -> Result<Option<Spanning<Self>>>

Parses this attribute from the provided multiple syn::Attributes with the provided Parser, merging them, and preserving their Span.

Source

fn parse_attrs( attrs: impl AsRef<[Attribute]>, name: &Ident, ) -> Result<Option<Spanning<Self>>>

Parses this attribute from the provided multiple syn::Attributes with the default Parse, merging them, and preserving their Span.

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.

Implementors§