bit-bounds 1.0.0

Helper traits for const generic bitwise bounds
Documentation
  • Coverage
  • 2.63%
    1 out of 38 items documented1 out of 32 items with examples
  • Size
  • Source code size: 5.31 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.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
  • Bajix/bit-bounds
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Bajix

License Cargo Documentation

Helper traits for const generic bitwise bounds

#![allow(incomplete_features)]
#![feature(generic_const_exprs)]

use bit_bounds::{IsPowerOf2, usize::*};

struct Buffer<const N: usize> {
  inner: [usize; N],
}

impl<const N: usize> Buffer<N>
where
  Int<N>: IsPowerOf2
{
  pub const fn new() -> Self {
    Buffer { inner: [0; N] }
  }
}

fn extract_index<const N: usize>(counter: usize) -> usize
where
  Int<N>: IsPowerOf2,
  Int<N>: BitsAllClear<{ (u32::MAX as usize) << 32 }>,
{
  (counter >> 32) & (N - 1)
}