Expand description
Definitions of built-in macros.
Most of the macro properties (stability, visibility, etc.) are taken from the source code here, with exception of expansion functions transforming macro inputs into outputs, those functions are provided by the compiler.
Macros§
- deref
Experimental - Unstable placeholder for deref patterns.
- type_
ascribe Experimental - Unstable placeholder for type ascription.
Attribute Macros§
- derive
- Attribute macro used to apply derive macros.
- global_
allocator - Attribute macro applied to a static to register it as a global allocator.
- test
- Attribute macro applied to a function to turn it into a unit test.
- alloc_
error_ handler Experimental - Attribute macro applied to a function to register it as a handler for allocation failure.
- autodiff
Experimental - Automatic Differentiation macro which allows generating a new function to compute
the derivative of a given function. It may only be applied to a function.
The expected usage syntax is
#[autodiff(NAME, MODE, INPUT_ACTIVITIES, OUTPUT_ACTIVITY)]
where: NAME is a string that represents a valid function name. MODE is any of Forward, Reverse, ForwardFirst, ReverseFirst. INPUT_ACTIVITIES consists of one valid activity for each input parameter. OUTPUT_ACTIVITY must not be set if we implicitly return nothing (or explicitly return-> ()
). Otherwise it must be set to one of the allowed activities. - bench
Experimental - Attribute macro applied to a function to turn it into a benchmark test.
- cfg_
accessible Experimental - Keeps the item it’s applied to if the passed path is accessible, and removes it otherwise.
- cfg_
eval Experimental - Expands all
#[cfg]
and#[cfg_attr]
attributes in the code fragment it’s applied to. - contracts_
ensures Experimental - Attribute macro applied to a function to give it a post-condition.
- contracts_
requires Experimental - Attribute macro applied to a function to give it a precondition.
- define_
opaque Experimental - Provide a list of type aliases and other opaque-type-containing type definitions to an item with a body. This list will be used in that body to define opaque types’ hidden types. Can only be applied to things that have bodies.
- derive_
const Experimental - Attribute macro used to apply derive macros for implementing traits in a const context.
- test_
case Experimental - An implementation detail of the
#[test]
and#[bench]
macros.