pub(crate) trait SingleAttributeParser<S: Stage>: 'static {
const PATH: &[Symbol];
const ON_DUPLICATE: OnDuplicate<S>;
const ALLOWED_TARGETS: AllowedTargets;
const TEMPLATE: AttributeTemplate;
// Required method
fn convert(
cx: &mut AcceptContext<'_, '_, S>,
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§
Sourceconst PATH: &[Symbol]
const PATH: &[Symbol]
The single path of the attribute this parser accepts.
If you need the parser to accept more than one path, use AttributeParser instead
Sourceconst ON_DUPLICATE: OnDuplicate<S>
const ON_DUPLICATE: OnDuplicate<S>
Configures what to do when when the same attribute is applied more than once on the same syntax node.
const ALLOWED_TARGETS: AllowedTargets
Sourceconst TEMPLATE: AttributeTemplate
const TEMPLATE: AttributeTemplate
The template this attribute parser should implement. Used for diagnostics.
Required Methods§
Sourcefn convert(
cx: &mut AcceptContext<'_, '_, S>,
args: &ArgParser,
) -> Option<AttributeKind>
fn convert( cx: &mut AcceptContext<'_, '_, S>, 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.