A macro for easy generation and wrapping of a const function under a const_fn feature gate.
toml
const_ft = { version = "0.1" }
You can enable the feature by having a feature in the project enable the feature from the crate:
toml
[features]
const = ["const_ft/const_fn"]
rust
const_ft! {
pub fn some_function() -> usize {
1usize
}
By using the macro, your code changes from ```rust
#[cfg(feature = "const_fn")]
pub const fn some_function() -> usize {
1usize
}
#[cfg(not(feature = "const_fn"))]
pub fn some_function() -> usize {
1usize
}
```
to
```rust
#[macrouse] extern crate constft;
constft! { pub fn somefunction() -> usize { 1usize } } ```