A trait marking valid underlying bitset storage types and providing the operations `EnumSet` and related types use. # Safety Note that `iter` *MUST* be implemented correctly and only return bits that are actually set in the representation, or else it will cause undefined behavior upstream in `EnumSet`.
| 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 | Send + |
| 26 | Sync + |
| 27 | // Operations used by enumset |
| 28 | BitAnd<Output = Self> + |
| 29 | BitOr<Output = Self> + |
| 30 | BitXor<Output = Self> + |
| 31 | Not<Output = Self> + |
| 32 | { |
| 33 | const PREFERRED_ARRAY_LEN: usize; |
| 34 | const WIDTH: u32; |
| 35 | const EMPTY: Self; |
| 36 | |
| 37 | fn is_empty(&self) -> bool; |
| 38 | |
| 39 | fn add_bit(&mut self, bit: u32); |
| 40 | fn remove_bit(&mut self, bit: u32); |
| 41 | fn has_bit(&self, bit: u32) -> bool; |
| 42 | |
| 43 | fn count_ones(&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 try_from_u8(v: u8) -> Option<Self>; |
| 65 | fn try_from_u16(v: u16) -> Option<Self>; |
| 66 | fn try_from_u32(v: u32) -> Option<Self>; |
| 67 | fn try_from_u64(v: u64) -> Option<Self>; |
| 68 | fn try_from_u128(v: u128) -> Option<Self>; |
| 69 | fn try_from_usize(v: usize) -> Option<Self>; |
| 70 | |
| 71 | fn try_to_u8(&self) -> Option<u8>; |
| 72 | fn try_to_u16(&self) -> Option<u16>; |
| 73 | fn try_to_u32(&self) -> Option<u32>; |
| 74 | fn try_to_u64(&self) -> Option<u64>; |
| 75 | fn try_to_u128(&self) -> Option<u128>; |
nothing calls this directly
no outgoing calls
no test coverage detected