MCPcopy Index your code
hub / github.com/Lymia/enumset / try_from_array

Method try_from_array

enumset/src/impl_set.rs:467–477  ·  view source on GitHub ↗

Attempts to construct a bitset from a `[u64; O]`. If a bit that doesn't correspond to an enum variant is set, this method will return `None`.

(bits: [u64; O])

Source from the content-addressed store, hash-verified

465 ///
466 /// If a bit that doesn't correspond to an enum variant is set, this method will return `None`.
467 pub fn try_from_array<const O: usize>(bits: [u64; O]) -> Option<Self> {
468 let bits = T::Repr::try_from_u64_array::<O>(bits);
469 let mask = T::ALL_BITS;
470 bits.and_then(|bits| {
471 if bits.and_not(mask).is_empty() {
472 Some(EnumSet { repr: bits })
473 } else {
474 None
475 }
476 })
477 }
478
479 /// Constructs a bitset from a `[u64; O]`, ignoring bits that do not correspond to a variant.
480 pub fn from_array_truncated<const O: usize>(bits: [u64; O]) -> Self {

Callers

nothing calls this directly

Calls 2

is_emptyMethod · 0.80
and_notMethod · 0.80

Tested by

no test coverage detected