[][qualifier_attr
]
[][qualifier_attr
]
[][qualifier_attr
/docs]
[][qualifier_attr
/license]
[][qualifier_attr
/depstatus]
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 fn
unsafe
- unsafe code, e.g. unsafe fn
, unsafe trait
const
- code that may run at compile time, e.g. const fn
extern "ABI"
- specifying an ABI, e.g. extern "C" fn
```rust
extern crate qualifier_attr;
// We can add a qualifier to a function // with an attribute.
fn const_fn() -> u32 { 42 }
const CONSTRES: u32 = constfn();
// It's not so impressive on its own,
// but with cfg_attr
, it can be conditional.
fn externcfn() -> u32 { 42 }
// It even works with types, imports, and more! mod foo { #[qualifiers(pub)] struct Foo { x: i32, y: i32, } }
use foo::Foo;
// Traits and implementations too!?
trait Quux { fn quuxthething(); }
impl Quux for Foo { fn quuxthething() { println!("The thing was quuxed."); } }
// You can add qualifiers to the fields of a // struct as well with this special attribute.
struct Point2 { x: i32, y: i32, }
struct Point3(i32, i32, i32); ```
Learn more about cfg_attr
here.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.