Module primitive

Module primitive 

Source
Expand description

The “impls” for primitive types such as bool and u8

/// Pseudo-code
mod ::const_dispatch::primitive {
    impl ConstDispatch for bool { /* magic */ }
    impl ConstDispatch for u8 { /* magic */ }
}

§Example

use ::const_dispatch::{const_dispatch, primitive::bool};

fn inner<const VERBOSE: bool>() {
    // ...
}

fn main() {
    let verbose = ::std::env::var("VERBOSE").map_or(false, |s| s == "1");
    const_dispatch!(verbose, |const VERBOSE: bool| {
        inner::<VERBOSE>()
    })
}

Make sure to import these (either individually, or as a blob import from the crate::prelude::*) in order for const_dispatch! to work with u8 and bool properly.

Re-exports§

pub use bool;
pub use u8;