Skip to content

Support private bitfields #57

@vhu43

Description

@vhu43

Sorry, new to rust, and I might have missed something, but would it be possible to add private bitfields if they don't already exist?

pub mod foo {
    #[bitfield(u8, default = 0x00)]
    pub struct bar {
        #[bit(0, r)]
        pub cool: bool,

        #[bits(1..=4, r)]
        hotness: u4, // I want this to be private

        #[bits(5..=7, r)]
        pub weirdness: u3,
    }

    impl bar {
        pub fn hotness(&self) -> u8 {
            8 * self.hotness().value() // So hotness can be a multiple of 8
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions