Expand description
§typebitset
An type-level number and list implementation for Rust.
§Type-level number
Type-level number is available via FromNum<N>
(by type) or from_num::<N>()
(by value) interface, or directly constructed using Cons
, Bit0
and Bit1
.
let v1: Cons<Bit1, Cons<Bit0, Bit1>> = from_num::<5>();
let v2: Cons<Bit1, Bit1> = from_num::<3>() ;
let v3: Bit1 = v1 & v2;
println!("v3 = {}", &v3);
let v4: FromNum<7> = v1 | v2;
let v5: <<Bit0 as ShiftRaising>::Output as Push<Bit1>>::Output = Default::default();
All type-level number implements trait Value
, which supports some methods to convert between type, value and usize
number.
Some operations are supported for type-level number.
use typebitset::{FromNum, from_num, ShiftRaising, ShiftLowering};
let v1 = from_num::<7>();
let v2: FromNum<3> = v1.shift_raising();
println!("v2 = {}", &v2);
§Type-level list
typebitset supports type-level list, which contains type-level numbers. Some operations are implemented on type-level list.
Modules§
Structs§
- Bit0
- Represents a bitset represented as zero.
Only if a bitset equals to
Bit0
, the bitset means zero. SeeValue
for details. - Bit1
- Represents a bitset represented as one.
See
Value
for details. - Cons
- Implementation of bitset. See
Value
Traits§
- Bit
- A trait which represents a bit.
- Positive
- A trait implemented if the bitset is positive (not zero).
- Push
- Make left shift of the bitset and use give bit as the LSB.
- Push
After Msb - Concat bitset S after the MSB of Self.
- Replace
Ones - Replacing Bit1 in Self with S.
S should be
Positive
. - Shift
Lowering - Generate right shift of the bitset.
- Shift
Raising - Generate left shift of the bitset.
- Value
- The main trait represents a bitset.
Functions§
Type Aliases§
- FromNum
- Generate
Value
type for small numberN
.FromNum<N>
is defined whereN
is in0..2 ** 7
.