tibitset 0.1.0

TiBitSet is a simple bitset replacement for HashSet
Documentation
  • Coverage
  • 100%
    41 out of 41 items documented1 out of 37 items with examples
  • Size
  • Source code size: 68.55 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 7.73 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
  • bestouff/tibitset
    5 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • bestouff

tibitset

A simple bitset container for Rust, meant to be a replacement for HashSet

Please read the API documentation here

build_status crates

Philosophy

This crate is a fork from fixedbitset with added genericity over its bit indexing type. It is the same idea like TiVec is for Vec, a collection which you can use with a custom index type which is not usize. It's also a nearly-drop-in replacement for HashSet which you can use when you have a limited index space with mostly full collections.

Usage

[dependencies]
tibitset = "0.1"
use tibitset::TiBitSet;
use std::convert::TryInto;

struct CustomIndex(pub u16);

impl From<usize> for CustomIndex {
    fn from(value: usize) -> Self {
        CustomIndex(value.try_into().expect("value too large to fit u16"))
    }
}
impl Into<usize> for CustomIndex {
    fn into(self) -> usize {
        self.0.into()
    }
}

let fb: TiBitSet::<CustomIndex>::with_capacity(10);
fb.set(CustomIndex(2), true);
assert!(!fb.contains(CustomIndex(1)));
assert!(fb.contains(CustomIndex(2)));

License

Dual-licensed to be compatible with the Rust project.

Licensed under the Apache License, Version 2.0 or the MIT license, at your option. This file may not be copied, modified, or distributed except according to those terms.