Attempts to construct a bitset from a `&[u64]`. If a bit that doesn't correspond to an enum variant is set, this method will return `None`.
(bits: &[u64])
| 539 | /// |
| 540 | /// If a bit that doesn't correspond to an enum variant is set, this method will return `None`. |
| 541 | pub fn try_from_slice(bits: &[u64]) -> Option<Self> { |
| 542 | let bits = T::Repr::try_from_u64_slice(bits); |
| 543 | let mask = T::ALL_BITS; |
| 544 | bits.and_then(|bits| { |
| 545 | if bits.and_not(mask).is_empty() { |
| 546 | Some(EnumSet { repr: bits }) |
| 547 | } else { |
| 548 | None |
| 549 | } |
| 550 | }) |
| 551 | } |
| 552 | |
| 553 | /// Constructs a bitset from a `&[u64]`, ignoring bits that do not correspond to a variant. |
| 554 | pub fn from_slice_truncated(bits: &[u64]) -> Self { |