Skip to main content

Module macros

Module macros 

Source

MacrosΒ§

c_enum πŸ”’
Represent a C enum as Rust constants and a type.
cfg_if πŸ”’
A macro for defining #cfg if-else statements.
custom_struct πŸ”’
Emit a struct with the given derive attributes plus a generated Default impl. Ensure that the record has an additional private field added to replicate #[non_exhaustive], unless it is annotated with #[exhaustive].
deprecated_mach πŸ”’
e πŸ”’
Implement Clone and Copy for an enum, as well as Debug, Eq, Hash, and PartialEq if the extra_traits feature is enabled.
emit_struct_default_body πŸ”’
Expands the Default implementation of the record defined at [custom_struct], with either one of an additional private field initialized to the unit value, or the record’s fields verbatim.
emit_struct_definition πŸ”’
Expands the definition of the record defined at [custom_struct], with either one of an additional private field or with its verbatim fields.
emit_union_default_via_unsafe_zeroed πŸ”’
Add a Default impl that is just mem::zeroed.
extern_ty πŸ”’
Create an uninhabited type that can’t be constructed. It implements Debug, Clone, and Copy, but these aren’t meaningful for extern types so they should eventually be removed.
f πŸ”’
Define a function that can be either safe or unsafe and optionally const. This always marks the function inline and adds extern "C".
offset_of πŸ”’
Polyfill for std’s offset_of.
prelude πŸ”’
Create an internal crate prelude with core reexports and common types.
s πŸ”’
Implement Clone, Copy, and Debug for one or more structs, as well as PartialEq, Eq, and Hash if the extra_traits feature is enabled.
s2 πŸ”’
Like s, but (1) generates a Default impl for every struct in the block, and (2) adds a private field to the struct to replicate the effects of the non_exhaustive attribute while rust-lang/rust#132699 gets sorted out.
s_no_extra_traits πŸ”’
Implement Clone, Copy, and Debug for one or more structs/unions, but exclude PartialEq, Eq, and Hash.
s_no_extra_traits2 πŸ”’
Like [s_no_extra_traits], but (1) generates a Default impl for every struct in the block, and (2) adds a private field to replicate the effects of the built-in non_exhaustive attribute while rust-lang/rust#132699 gets sorted out.
s_paren πŸ”’
Implement Clone, Copy, and Debug for a tuple struct, as well as PartialEq, Eq, and Hash if the extra_traits feature is enabled.
union_with_debug πŸ”’
Emit a union plus its Debug impl.