| 1 |
#![allow(missing_docs)] |
| 2 |
|
| 3 |
mod array; |
| 4 |
mod primitive; |
| 5 |
|
| 6 |
use core::fmt::Debug; |
| 7 |
use core::hash::Hash; |
| 8 |
use core::ops::*; |
| 9 |
|
| 10 |
/// A trait marking valid underlying bitset storage types and providing the |
| 11 |
/// operations `EnumSet` and related types use. |
| 12 |
/// |
| 13 |
/// # Safety |
| 14 |
/// |
| 15 |
/// Note that `iter` *MUST* be implemented correctly and only return bits that |
| 16 |
/// are actually set in the representation, or else it will cause undefined |
| 17 |
/// behavior upstream in `EnumSet`. |
| 18 |
pub trait EnumSetTypeRepr : |
| 19 |
// Basic traits used to derive traits |
| 20 |
Copy + |
| 21 |
Ord + |
| 22 |
Eq + |
| 23 |
Debug + |
| 24 |
Hash + |
| 25 |
// Operations used by enumset |
| 26 |
BitAnd<Output = Self> + |
| 27 |
BitOr<Output = Self> + |
| 28 |
BitXor<Output = Self> + |
| 29 |
Not<Output = Self> + |
| 30 |
{ |
| 31 |
const PREFERRED_ARRAY_LEN: usize; |
| 32 |
const WIDTH: u32; |
| 33 |
const EMPTY: Self; |
| 34 |
|
| 35 |
fn is_empty(&self) -> bool; |
| 36 |
|
| 37 |
fn add_bit(&mut self, bit: u32); |
| 38 |
fn remove_bit(&mut self, bit: u32); |
| 39 |
fn has_bit(&self, bit: u32) -> bool; |
| 40 |
|
| 41 |
fn count_ones(&self) -> u32; |
| 42 |
fn leading_zeros(&self) -> u32; |
| 43 |
fn trailing_zeros(&self) -> u32; |
| 44 |
|
| 45 |
fn and_not(&self, other: Self) -> Self; |
| 46 |
|
| 47 |
type Iter: Iterator<Item = u32> + DoubleEndedIterator + Clone + Debug; |
| 48 |
fn iter(self) -> Self::Iter; |
| 49 |
|
| 50 |
fn from_u8(v: u8) -> Self; |
| 51 |
fn from_u16(v: u16) -> Self; |
| 52 |
fn from_u32(v: u32) -> Self; |
| 53 |
fn from_u64(v: u64) -> Self; |
| 54 |
fn from_u128(v: u128) -> Self; |
| 55 |
fn from_usize(v: usize) -> Self; |
| 56 |
|
| 57 |
fn to_u8(&self) -> u8; |
| 58 |
fn to_u16(&self) -> u16; |
| 59 |
fn to_u32(&self) -> u32; |
| 60 |
fn to_u64(&self) -> u64; |
| 61 |
fn to_u128(&self) -> u128; |
| 62 |
fn to_usize(&self) -> usize; |
| 63 |
|
| 64 |
fn from_u8_opt(v: u8) -> Option<Self>; |
| 65 |
fn from_u16_opt(v: u16) -> Option<Self>; |
| 66 |
fn from_u32_opt(v: u32) -> Option<Self>; |
| 67 |
fn from_u64_opt(v: u64) -> Option<Self>; |
| 68 |
fn from_u128_opt(v: u128) -> Option<Self>; |
| 69 |
fn from_usize_opt(v: usize) -> Option<Self>; |
| 70 |
|
| 71 |
fn to_u8_opt(&self) -> Option<u8>; |
| 72 |
fn to_u16_opt(&self) -> Option<u16>; |
| 73 |
fn to_u32_opt(&self) -> Option<u32>; |
| 74 |
fn to_u64_opt(&self) -> Option<u64>; |
| 75 |
fn to_u128_opt(&self) -> Option<u128>; |
| 76 |
fn to_usize_opt(&self) -> Option<usize>; |
| 77 |
|
| 78 |
fn to_u64_array<const O: usize>(&self) -> [u64; O]; |
| 79 |
fn to_u64_array_opt<const O: usize>(&self) -> Option<[u64; O]>; |
| 80 |
|
| 81 |
fn from_u64_array<const O: usize>(v: [u64; O]) -> Self; |
| 82 |
fn from_u64_array_opt<const O: usize>(v: [u64; O]) -> Option<Self>; |
| 83 |
|
| 84 |
fn to_u64_slice(&self, out: &mut [u64]); |
| 85 |
#[must_use] |
| 86 |
fn to_u64_slice_opt(&self, out: &mut [u64]) -> Option<()>; |
| 87 |
|
| 88 |
fn from_u64_slice(v: &[u64]) -> Self; |
| 89 |
fn from_u64_slice_opt(v: &[u64]) -> Option<Self>; |
| 90 |
} |
| 91 |
|
| 92 |
pub use array::ArrayRepr; |