[−][src]Crate const_fn
An attribute for easy generation of a const function with conditional compilations.
Examples
When using like the following functions to control unstable features:
[features]
const = []
It can be written as follows:
#![cfg_attr(feature = "const", feature(const_fn, const_vec_new))] #[const_fn(feature = "const")] pub const fn empty_vec<T>() -> Vec<T> { Vec::new() }
Code like this will be generated:
#![cfg_attr(feature = "const", feature(const_fn, const_vec_new))] #[cfg(feature = "const")] pub const fn empty_vec<T>() -> Vec<T> { Vec::new() } #[cfg(not(feature = "const"))] pub fn empty_vec<T>() -> Vec<T> { Vec::new() }
See test_suite for more examples.
Attribute Macros
const_fn | An attribute for easy generation of a const function with conditional compilations. |