fn generate_bitfield_size(&self) -> TokenStream2 {
        let span = self.item_struct.span();
        let sum = self
            .item_struct
            .fields
            .iter()
            .map(|field| {
                let span = field.span();
                let ty = &field.ty;
                quote_spanned!(span=>
                    <#ty as ::modular_bitfield::Specifier>::BITS
                )
            })
            .fold(quote_spanned!(span=> 0usize), |lhs, rhs| {
                quote_spanned!(span =>
                    #lhs + #rhs
                )
            });
        quote_spanned!(span=>
            { #sum }
        )
    }
/// Generates the expression denoting the sum of all field bit specifier sizes.
///
/// # Example
///
/// For the following struct:
///
/// ```
/// # use modular_bitfield::prelude::*;
/// #[bitfield]
/// pub struct Color {
///     r: B8,
///     g: B8,
///     b: B8,
///     a: bool,
///     rest: B7,
/// }
/// ```
///
/// We generate the following tokens:
///
/// ```
/// # use modular_bitfield::prelude::*;
/// {
///     0usize +
///     <B8 as ::modular_bitfield::Specifier>::BITS +
///     <B8 as ::modular_bitfield::Specifier>::BITS +
///     <B8 as ::modular_bitfield::Specifier>::BITS +
///     <bool as ::modular_bitfield::Specifier>::BITS +
///     <B7 as ::modular_bitfield::Specifier>::BITS
/// }
/// # ;
/// ```
///
/// Which is a compile time evaluatable expression.
Generates the expression denoting the sum of all field bit specifier sizes.
Generates the expression denoting the sum of all field bit specifier sizes .
fn generate_bitfield_size(&self) -> TokenStream2 {
        let span = self.item_struct.span();
        let sum = self
            .item_struct
            .fields
            .iter()
            .map(|field| {
                let span = field.span();
                let ty = &field.ty;
                quote_spanned!(span=>
                    <#ty as ::modular_bitfield::Specifier>::BITS
                )
            })
            .fold(quote_spanned!(span=> 0usize), |lhs, rhs| {
                quote_spanned!(span =>
                    #lhs + #rhs
                )
            });
        quote_spanned!(span=>
            { #sum }
        )
    }
fn generate_bitfield_size ( & self ) -> TokenStream2 { let span = self . item_struct . span ( ) ; let sum = self . item_struct . fields . iter ( ) . map ( | field | { let span = field . span ( ) ; let ty = & field . ty ; quote_spanned ! ( span ty as modular_bitfield Specifier BITS ) } ) . fold ( quote_spanned ! ( span 0usize ) , | lhs , rhs | { quote_spanned ! ( span lhs rhs ) } ) ; quote_spanned ! ( span { sum } ) }
Generates the expression denoting the sum of all field bit specifier sizes.
Generates the expression denoting the sum of all field bit specifier sizes .
&self
&self
example
For the following struct.


For the following struct .
use modular_bitfield::prelude::*;
None
[bitfield]


We generate the following tokens.


We generate the following tokens .
use modular_bitfield::prelude::*;
None
;


Which is a compile time evaluatable expression.
Which is a compile time evaluatable expression .