pub(crate) trait SingleAttributeParser: 'static {
const PATH: &[Symbol];
const STABILITY: AttributeStability;
const ALLOWED_TARGETS: AllowedTargets;
const TEMPLATE: AttributeTemplate;
const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error;
const SAFETY: AttributeSafety = AttributeSafety::Normal;
// Required method
fn convert(
cx: &mut 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§
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
const STABILITY: AttributeStability
const ALLOWED_TARGETS: AllowedTargets
Sourceconst TEMPLATE: AttributeTemplate
const TEMPLATE: AttributeTemplate
The template this attribute parser should implement. Used for diagnostics.
Provided Associated Constants§
Sourceconst ON_DUPLICATE: OnDuplicate = OnDuplicate::Error
const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error
Configures what to do when when the same attribute is applied more than once on the same syntax node.
const SAFETY: AttributeSafety = AttributeSafety::Normal
Required Methods§
Sourcefn convert(
cx: &mut AcceptContext<'_, '_>,
args: &ArgParser,
) -> Option<AttributeKind>
fn convert( cx: &mut 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".