// SPDX-FileCopyrightText: 2017 - 2021 Kamila Borowska <kamila@borowska.pw> // SPDX-FileCopyrightText: 2021 Bruno Corrêa Zimmermann <brunoczim@gmail.com> // SPDX-FileCopyrightText: 2021 micycle // SPDX-FileCopyrightText: 2023 Nicolas Carranza <nicarran@yandex.com> // // SPDX-License-Identifier: MIT OR Apache-2.0
usecrate::{enum_map, EnumArray, EnumMap}; use core::fmt::{self, Debug, Formatter}; use core::hash::{Hash, Hasher}; use core::iter::{Extend, FromIterator}; use core::ops::{Index, IndexMut};
impl<K: EnumArray<V>, V> IndexMut<K> for EnumMap<K, V> { #[inline] fn index_mut(&mutself, key: K) -> &mut V {
&mutself.as_mut_slice()[key.into_usize()]
}
}
// Implementations provided by derive attribute are too specific, and put requirements on K. // This is caused by rust-lang/rust#26925. impl<K: EnumArray<V>, V> Clone for EnumMap<K, V> where
K::Array: Clone,
{ #[inline] fn clone(&self) -> Self {
EnumMap {
array: self.array.clone(),
}
}
}
impl<K: EnumArray<V>, V> Copy for EnumMap<K, V> where K::Array: Copy {}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.