bitable 0.1.0

An all-const, compile-time checked, safe bit handling library with zero runtime overhead
Documentation
/// Syntaxic sugar: define arbitrary bit `Flag`s and `Field`s
#[macro_export]
macro_rules! bits {
    (
        $(
            $( #[ $attr:meta ] )*
            $vis:vis const $name:ident : $type:ident < $( $args:literal ),+ >;
        )*
    ) => {
        $(
            bits! { @expand $( #[ $attr ] )* $vis const $name : $type ( $( $args ),+ ) }
        )*
    };

    (
        $(
            $( #[ $attr:meta ] )*
            $vis:vis $name:ident : $type:ident < $( $args:literal ),+ >;
        )*
    ) => {
        $(
            bits! { @expand $( #[ $attr ] )* $vis $name : $type ( $( $args ),+ ) }
        )*
    };

    // Internal helper to expand "bit" with attributes
    ( @expand $( #[ $attr:meta ] )* $vis:vis const $name:ident : Flag ( $offset:expr ) ) => {
        $( #[ $attr ] )*
        $vis const $name: bitable::bit::Flag<$offset> = bitable::bit::Flag::<$offset>::new();
    };
    ( @expand $( #[ $attr:meta ] )* $vis:vis $name:ident : Flag ( $offset:expr ) ) => {
        $( #[ $attr ] )*
        $vis $name: bitable::bit::Flag<$offset> = bitable::bit::Flag::<$offset>::new();
    };

    // Internal helper to expand "field" with attributes
    ( @expand $( #[ $attr:meta ] )* $vis:vis const $name:ident : Field ( $offset:expr, $size:expr ) ) => {
        $( #[ $attr ] )*
        $vis const $name: bitable::bit::Field<$offset, $size> = bitable::bit::Field::<$offset, $size>::new();
    };
    ( @expand $( #[ $attr:meta ] )* $vis:vis $name:ident : Field ( $offset:expr, $size:expr ) ) => {
        $( #[ $attr ] )*
        $vis $name: bitable::bit::Field<$offset, $size> = bitable::bit::Field::<$offset, $size>::new();
    };
}