Skip to content

Bug with Len: random padding bits are taken into account #30

@damv

Description

@damv

Thanks for the crate, I found out that really counter intuitive behavior:

use bitmaps::Bitmap;

#[cfg(test)]
mod tests {
    #[test]
    fn bitmap_len() {
        let mut a = Bitmap::<10>::new();
        assert_eq!(a.len(), 0);
        a.invert();
        assert_eq!(a.len(), 10); // Assertion `left == right` failed left: 16 right: 10
    }
}

len() function takes into account the 6 padding bits.

My understanding was that the library abstracted the padding bits so only the size requested by the user has an importance (as the example in the README suggests). If I understood well the intention, then it is a bug.

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