MCPcopy Create free account
hub / github.com/Lymia/enumset / try_from_slice

Method try_from_slice

enumset/src/impl_set.rs:541–551  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 2

is_emptyMethod · 0.80
and_notMethod · 0.80

Tested by

no test coverage detected