macro_rules! ctor {
($( #[feature($fname:ident)] )* #[ctor $(($($meta:tt)*))?] $(#[$imeta:meta])* pub ( $($extra:tt)* ) $($item:tt)*) => { ... };
($( #[feature($fname:ident)] )* #[ctor $(($($meta:tt)*))?] $(#[$imeta:meta])* pub $($item:tt)*) => { ... };
($( #[feature($fname:ident)] )* #[ctor $(($($meta:tt)*))?] $(#[$imeta:meta])* fn $($item:tt)*) => { ... };
($( #[feature($fname:ident)] )* #[ctor $(($($meta:tt)*))?] $(#[$imeta:meta])* unsafe $($item:tt)*) => { ... };
($( #[feature($fname:ident)] )* #[ctor $(($($meta:tt)*))?] $(#[$imeta:meta])* static $($item:tt)*) => { ... };
}Expand description
Parse a #[ctor]-annotated item as if it were a proc-macro.
This macro supports both the fn and static forms of the #[ctor]
attribute, including attribute parameters.
ctor! {
#[ctor(link_section = "...")]
unsafe fn foo() { /* ... */ }
}
ctor! {
#[ctor(link_section = "...")]
static FOO: std::collections::HashMap<u32, String> = unsafe {
let mut m = std::collections::HashMap::new();
m.insert(1, "foo".to_string());
m
};
}