Expand description
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_let, const_vec_new))]
#[const_fn(feature = "const")]
pub const fn empty_vec<T>() -> Vec<T> {
let vec = Vec::new();
vec
}
Code like this will be generated:
#![cfg_attr(feature = "const", feature(const_fn, const_let, const_vec_new))]
#[cfg(feature = "const")]
pub const fn empty_vec<T>() -> Vec<T> {
let vec = Vec::new();
vec
}
#[cfg(not(feature = "const"))]
pub fn empty_vec<T>() -> Vec<T> {
let vec = Vec::new();
vec
}
Rust Version
The current minimum required Rust version is 1.30.
Attribute Macros
An attribute for easy generation of a const function with conditional compilations.