qualifier_attr
Procedural macro attributes for adding "qualifiers" to various items.
At the moment, the crate supports the following "qualifiers":
pub,pub(crate), etc. - visibility and restrictiondefault- default implementations (a feature of specialization)async- asynchronous code, e.g.async fnunsafe- unsafe code, e.g.unsafe fn,unsafe traitconst- code that may run at compile time, e.g.const fnextern "ABI"- specifying an ABI, e.g.extern "C" fn
Limitations
- It seems that rust-analyzer will sometimes complain when the attribute is used with modules.
Examples
extern crate qualifier_attr;
// We can add a qualifier to a function
// with an attribute.
const CONST_RES: u32 = const_fn;
// It's not so impressive on its own,
// but with `cfg_attr`, it can be conditional.
// It even works with types, imports, and more!
use Foo;
// Traits and implementations too!?
// You can add qualifiers to the fields of a
// struct as well with this special attribute.
;
Learn more about cfg_attr here.