rle-bitset 0.1.0

A no-std, no-alloc trait for querying and manipulating bits in a `[usize]` and iterating their run lengths.
Documentation
  • Coverage
  • 78.57%
    11 out of 14 items documented0 out of 10 items with examples
  • Size
  • Source code size: 26.45 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.58 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • irrustible/rle-bitset
    4 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jjl

rle-bitset

License Package Documentation

A no-std, no-alloc trait for querying and manipulating bits in a [[usize]] and iterating their run lengths.

Usage

use rle_bitset::*;

#[test]
fn one_two() {
    let mut x: [usize; 4] = [0, 0, 0, 0];
    let over = WORD_WIDTH * 4;
    x.set_bit(WORD_WIDTH, true).unwrap();
    assert_eq!(x.get_bit(WORD_WIDTH).unwrap(), true);
    {
        let mut iter = x.run_lengths(..).unwrap();
        assert_eq!(Some(RL::new(false, 0, WORD_WIDTH)), iter.next());
        assert_eq!(Some(RL::new(true, WORD_WIDTH, WORD_WIDTH + 1)), iter.next());
        assert_eq!(Some(RL::new(false, WORD_WIDTH + 1, over)), iter.next());
        assert_eq!(None, iter.next());
    }
    x.set_bit(WORD_WIDTH - 1, true).unwrap();
    assert_eq!(x.get_bit(WORD_WIDTH - 1).unwrap(), true);
    {
        let mut iter = x.run_lengths(..).unwrap();
        assert_eq!(Some(RL::new(false, 0, WORD_WIDTH - 1)), iter.next());
        assert_eq!(Some(RL::new(true, WORD_WIDTH -1, WORD_WIDTH + 1)), iter.next());
        assert_eq!(Some(RL::new(false, WORD_WIDTH + 1, over)), iter.next());
        assert_eq!(None, iter.next());
    }
}

Copyright and License

Copyright (c) 2020 James Laver, rle-bitset contributors

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.