const-ft 0.1.2

Macro for wrapping const fn in a feature gate.
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 39.76 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 630.82 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Dylan-DPC-zz/const-ft
    4 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Dylan-DPC

const-ft

Build Status Latest version Documentation Minimum rustc version License

A macro for easy generation and wrapping of a const function under a const_fn feature gate.

Installation:

 const-ft = { version =  "0.1" }

You can enable the feature by having a feature in the project enable the feature from the crate:

[features]
const = ["const-ft/const_fn"]

Usage:

const_ft! {
      pub fn some_function() -> usize {
         1usize
}

Requirement:

By using the macro, your code changes from

#![cfg_attr(feature = "const_fn", feature(const_fn))]

     #[cfg(feature = "const_fn")]
     pub const fn some_function() -> usize {
         1usize
     }
 
     #[cfg(not(feature = "const_fn"))]
     pub fn some_function() -> usize {
        1usize
     }

to

#![cfg_attr(feature = "const_fn", feature(const_fn))]

 #[macro_use]
 extern crate const_ft;

 const_ft! {
      pub fn some_function() -> usize {
         1usize
      }
 }