permutation-generator 0.1.3

A direct permutation generator
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
macro_rules! impl_factorial {
    ($fact:ident, $fact_type:ty) => {
        #[inline]
        pub(crate) fn $fact(nb_elems: u8) -> $fact_type {
            match nb_elems {
                0..=2 => <$fact_type>::from(nb_elems),
                _ => (1..=nb_elems).map(|i| <$fact_type>::from(i)).product(),
            }
        }
    };
}

impl_factorial!(factorial16, u16);
impl_factorial!(factorial64, u64);
impl_factorial!(factorial128, u128);