Trait SingleAttributeParser

Source
pub(crate) trait SingleAttributeParser: 'static {
    const PATH: &'static [Symbol];

    // Required methods
    fn on_duplicate(cx: &AcceptContext<'_>, first_span: Span);
    fn convert(
        cx: &AcceptContext<'_>,
        args: &ArgParser<'_>,
    ) -> Option<AttributeKind>;
}
Expand description

Alternative to AttributeParser that automatically handles state management. A slightly simpler and more restricted way to convert attributes. Assumes that an attribute can only appear a single time on an item, and errors when it sees more.

Single<T> where T: SingleAttributeParser implements AttributeParser.

SingleAttributeParser can only convert attributes one-to-one, and cannot combine multiple attributes together like is necessary for #[stable()] and #[unstable()] for example.

Required Associated Constants§

Source

const PATH: &'static [Symbol]

Required Methods§

Source

fn on_duplicate(cx: &AcceptContext<'_>, first_span: Span)

Caled when a duplicate attribute is found.

first_span is the span of the first occurrence of this attribute.

Source

fn convert( cx: &AcceptContext<'_>, args: &ArgParser<'_>, ) -> Option<AttributeKind>

Converts a single syntactical attribute to a single semantic attribute, or AttributeKind

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§