pub struct EnumMap<Ids: MapEnum, T>(/* private fields */);Expand description
Array which using enum as index
Implementations§
Source§impl<Ids: MapEnum, T> EnumMap<Ids, T>
impl<Ids: MapEnum, T> EnumMap<Ids, T>
Sourcepub const fn from_array(data: <Ids::Array as Array>::Map<T>) -> Self
pub const fn from_array(data: <Ids::Array as Array>::Map<T>) -> Self
Create map from array, recomand using map_new or map_enum!(if require const or move value) instead
Sourcepub const fn as_array(&self) -> &<Ids::Array as Array>::Map<T>
pub const fn as_array(&self) -> &<Ids::Array as Array>::Map<T>
Returns a shared reference to the underlying array.
Sourcepub const fn as_array_mut(&mut self) -> &mut <Ids::Array as Array>::Map<T>
pub const fn as_array_mut(&mut self) -> &mut <Ids::Array as Array>::Map<T>
Returns a mutable reference to the underlying array.
Sourcepub const fn into_array(self) -> <Ids::Array as Array>::Map<T>
pub const fn into_array(self) -> <Ids::Array as Array>::Map<T>
Consumes the enum map and returns the underlying array.
Sourcepub const fn remap<TIds: MapEnum<Array = Ids::Array>>(
&self,
) -> &EnumMap<TIds, T>
pub const fn remap<TIds: MapEnum<Array = Ids::Array>>( &self, ) -> &EnumMap<TIds, T>
Reinterprets the enum map as being indexed by a different enum type that shares the same underlying array.
Sourcepub const fn remap_mut<TIds: MapEnum<Array = Ids::Array>>(
&mut self,
) -> &mut EnumMap<TIds, T>
pub const fn remap_mut<TIds: MapEnum<Array = Ids::Array>>( &mut self, ) -> &mut EnumMap<TIds, T>
Mutable version of remap.
Sourcepub fn map_new(map: impl FnMut(Ids::Discriminant) -> T) -> Self
pub fn map_new(map: impl FnMut(Ids::Discriminant) -> T) -> Self
Create map by mapping closure, map will call excctally once for each enum variant, using map_enum! instead if require const or move value
Sourcepub const fn map_as_ref<'a>(&'a self) -> EnumMap<Ids, &'a T>
pub const fn map_as_ref<'a>(&'a self) -> EnumMap<Ids, &'a T>
Creates a new enum map where each element references the corresponding element in self.
Sourcepub const fn map_as_mut<'a>(&'a mut self) -> EnumMap<Ids, &'a mut T>
pub const fn map_as_mut<'a>(&'a mut self) -> EnumMap<Ids, &'a mut T>
Creates a new enum map where each element mutably references the corresponding element in self.
Sourcepub const fn transparent_wrap<U: TransparentWrapper<T>>(self) -> EnumMap<Ids, U>
pub const fn transparent_wrap<U: TransparentWrapper<T>>(self) -> EnumMap<Ids, U>
Wraps each element of the map in a TransparentWrapper, safe because the repr is identical.
Sourcepub const fn transparent_peel<U>(self) -> EnumMap<Ids, U>where
T: TransparentWrapper<U>,
pub const fn transparent_peel<U>(self) -> EnumMap<Ids, U>where
T: TransparentWrapper<U>,
Unwraps (peels) each element from a TransparentWrapper, safe because the repr is identical.
Trait Implementations§
Source§impl<Ids: MapEnum<Array: Array<Map<Fld>: Copy>>, Fld: BitsCast> BitsCast for EnumMap<Ids, Fld>
impl<Ids: MapEnum<Array: Array<Map<Fld>: Copy>>, Fld: BitsCast> BitsCast for EnumMap<Ids, Fld>
const BITS: u32
Source§fn from_underlying<Bits: PrimaryInt>(v: Bits) -> Self
fn from_underlying<Bits: PrimaryInt>(v: Bits) -> Self
Self::BITS, higher bits can be any valueSource§fn into_underlying<Bits: PrimaryInt>(sf: Self) -> Bits
fn into_underlying<Bits: PrimaryInt>(sf: Self) -> Bits
Self::BITS, higher bits can be any valueSource§impl<Ids: MapEnum<Array: Array<Map<T>: ConstDefault>>, T> ConstDefault for EnumMap<Ids, T>
impl<Ids: MapEnum<Array: Array<Map<T>: ConstDefault>>, T> ConstDefault for EnumMap<Ids, T>
impl<Ids: MapEnum<Array: Array<Map<T>: Copy>>, T> Copy for EnumMap<Ids, T>
impl<Ids: MapEnum<Array: Array<Map<T>: Eq>>, T> Eq for EnumMap<Ids, T>
Source§impl<Ids: MapEnum<Array: Array<Map<T>: Ord>>, T> Ord for EnumMap<Ids, T>
impl<Ids: MapEnum<Array: Array<Map<T>: Ord>>, T> Ord for EnumMap<Ids, T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<Ids: MapEnum<Array: Array<Map<T>: PartialOrd>>, T> PartialOrd for EnumMap<Ids, T>
impl<Ids: MapEnum<Array: Array<Map<T>: PartialOrd>>, T> PartialOrd for EnumMap<Ids, T>
impl<Ids: MapEnum<Array: Array<Map<T>: Pod>> + 'static, T: 'static> Pod for EnumMap<Ids, T>
Source§impl<Ids: MapEnum, T: TransparentWrapper<U>, U> TransparentWrapper<EnumMap<Ids, U>> for EnumMap<Ids, T>
impl<Ids: MapEnum, T: TransparentWrapper<U>, U> TransparentWrapper<EnumMap<Ids, U>> for EnumMap<Ids, T>
Source§fn wrap_ref(s: &Inner) -> &Self
fn wrap_ref(s: &Inner) -> &Self
Source§fn wrap_mut(s: &mut Inner) -> &mut Self
fn wrap_mut(s: &mut Inner) -> &mut Self
Source§fn wrap_slice(s: &[Inner]) -> &[Self]
fn wrap_slice(s: &[Inner]) -> &[Self]
Source§fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]
fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]
Source§fn peel_ref(s: &Self) -> &Inner
fn peel_ref(s: &Self) -> &Inner
Source§fn peel_mut(s: &mut Self) -> &mut Inner
fn peel_mut(s: &mut Self) -> &mut Inner
Source§fn peel_slice(s: &[Self]) -> &[Inner]
fn peel_slice(s: &[Self]) -> &[Inner]
Auto Trait Implementations§
impl<Ids, T> Freeze for EnumMap<Ids, T>
impl<Ids, T> RefUnwindSafe for EnumMap<Ids, T>
impl<Ids, T> Send for EnumMap<Ids, T>
impl<Ids, T> Sync for EnumMap<Ids, T>
impl<Ids, T> Unpin for EnumMap<Ids, T>
impl<Ids, T> UnsafeUnpin for EnumMap<Ids, T>
impl<Ids, T> UnwindSafe for EnumMap<Ids, T>
Blanket Implementations§
impl<T> AlignedRepr<T> for T
Source§impl<T> AlterRepr<T> for T
impl<T> AlterRepr<T> for T
const IS_SWEAP_BYTES: bool = const IS_SWEAP_BYTES: bool = false;
fn from_std_repr(v: T) -> T
fn into_std_repr(src: T) -> T
impl<T> AnyBitPattern for Twhere
T: Pod,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.