Struct otter_api_tests::shapelib::EnumMap [−]
pub struct EnumMap<K, V> where
K: Enum<V>, { /* fields omitted */ }
An enum mapping.
This internally uses an array which stores a value for each possible
enum value. To work, it requires implementation of internal (private,
although public due to macro limitations) trait which allows extracting
information about an enum, which can be automatically generated using
#[derive(Enum)]
macro.
Additionally, bool
and u8
automatically derives from Enum
. While
u8
is not technically an enum, it’s convenient to consider it like one.
In particular, reverse-complement in benchmark game could be using u8
as an enum.
Examples
use enum_map::{enum_map, Enum, EnumMap}; #[derive(Enum)] enum Example { A, B, C, } let mut map = EnumMap::default(); // new initializes map with default values assert_eq!(map[Example::A], 0); map[Example::A] = 3; assert_eq!(map[Example::A], 3);
Implementations
impl<K, V> EnumMap<K, V> where
K: Enum<V>,
K: Enum<V>,
pub fn values(&self) -> Values<'_, V>ⓘ
An iterator visiting all values. The iterator type is &V
.
Examples
use enum_map::enum_map; let map = enum_map! { false => 3, true => 4 }; let mut values = map.values(); assert_eq!(values.next(), Some(&3)); assert_eq!(values.next(), Some(&4)); assert_eq!(values.next(), None);
pub fn values_mut(&mut self) -> ValuesMut<'_, V>ⓘ
An iterator visiting all values mutably. The iterator type is &mut V
.
Examples
use enum_map::enum_map; let mut map = enum_map! { _ => 2 }; for value in map.values_mut() { *value += 2; } assert_eq!(map[false], 4); assert_eq!(map[true], 4);
impl<K, V> EnumMap<K, V> where
K: Enum<V>,
V: Default,
K: Enum<V>,
V: Default,
pub fn clear(&mut self)
Clear enum map with default values.
Examples
use enum_map::{Enum, EnumMap}; #[derive(Enum)] enum Example { A, B, } let mut enum_map = EnumMap::<_, String>::default(); enum_map[Example::B] = "foo".into(); enum_map.clear(); assert_eq!(enum_map[Example::A], ""); assert_eq!(enum_map[Example::B], "");
impl<K, V> EnumMap<K, V> where
K: Enum<V>,
K: Enum<V>,
pub fn from_array(array: <K as Enum<V>>::Array) -> EnumMap<K, V>
Creates an enum map from array.
pub fn iter(&self) -> Iter<'_, K, V>ⓘ
Returns an iterator over enum map.
pub fn iter_mut(&mut self) -> IterMut<'_, K, V>ⓘ
Returns a mutable iterator over enum map.
pub fn len(&self) -> usize
Returns number of elements in enum map.
pub fn swap(&mut self, a: K, b: K)
Swaps two indexes.
Examples
use enum_map::enum_map; let mut map = enum_map! { false => 0, true => 1 }; map.swap(false, true); assert_eq!(map[false], 1); assert_eq!(map[true], 0);
pub fn as_slice(&self) -> &[V]ⓘ
Converts an enum map to a slice representing values.
pub fn as_mut_slice(&mut self) -> &mut [V]ⓘ
Converts a mutable enum map to a mutable slice representing values.
Trait Implementations
impl<K, V> Clone for EnumMap<K, V> where
K: Enum<V>,
<K as Enum<V>>::Array: Clone,
K: Enum<V>,
<K as Enum<V>>::Array: Clone,
pub fn clone(&self) -> EnumMap<K, V>
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<K, V> Copy for EnumMap<K, V> where
K: Enum<V>,
<K as Enum<V>>::Array: Copy,
K: Enum<V>,
<K as Enum<V>>::Array: Copy,
impl<K, V> Debug for EnumMap<K, V> where
K: Enum<V> + Debug,
V: Debug,
K: Enum<V> + Debug,
V: Debug,
impl<K, V> Default for EnumMap<K, V> where
K: Enum<V>,
V: Default,
K: Enum<V>,
V: Default,
impl<'de, K, V> Deserialize<'de> for EnumMap<K, V> where
K: Enum<V> + Enum<Option<V>> + Deserialize<'de>,
V: Deserialize<'de>,
K: Enum<V> + Enum<Option<V>> + Deserialize<'de>,
V: Deserialize<'de>,
Requires crate feature "serde"
pub fn deserialize<D>(
deserializer: D
) -> Result<EnumMap<K, V>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
deserializer: D
) -> Result<EnumMap<K, V>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
impl<K, V> Eq for EnumMap<K, V> where
K: Enum<V>,
V: Eq,
K: Enum<V>,
V: Eq,
impl<'a, K, V> Extend<(&'a K, &'a V)> for EnumMap<K, V> where
K: Enum<V> + Copy,
V: Copy,
K: Enum<V> + Copy,
V: Copy,
pub fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = (&'a K, &'a V)>,
I: IntoIterator<Item = (&'a K, &'a V)>,
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<K, V> Extend<(K, V)> for EnumMap<K, V> where
K: Enum<V>,
K: Enum<V>,
pub fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = (K, V)>,
I: IntoIterator<Item = (K, V)>,
pub fn extend_one(&mut self, item: A)
[src]
pub fn extend_reserve(&mut self, additional: usize)
[src]
impl<K, V> Hash for EnumMap<K, V> where
K: Enum<V>,
V: Hash,
K: Enum<V>,
V: Hash,
pub fn hash<H>(&self, state: &mut H) where
H: Hasher,
H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<K, V> Index<K> for EnumMap<K, V> where
K: Enum<V>,
K: Enum<V>,
type Output = V
The returned type after indexing.
pub fn index(&self, key: K) -> &VⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
impl<K, V> IndexMut<K> for EnumMap<K, V> where
K: Enum<V>,
K: Enum<V>,
pub fn index_mut(&mut self, key: K) -> &mut VⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
impl<'a, K, V> IntoIterator for &'a EnumMap<K, V> where
K: Enum<V>,
K: Enum<V>,
type Item = (K, &'a V)
The type of the elements being iterated over.
type IntoIter = Iter<'a, K, V>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> <&'a EnumMap<K, V> as IntoIterator>::IntoIter
impl<K, V> IntoIterator for EnumMap<K, V> where
K: Enum<V>,
K: Enum<V>,
type Item = (K, V)
The type of the elements being iterated over.
type IntoIter = IntoIter<K, V>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> <EnumMap<K, V> as IntoIterator>::IntoIter
impl<'a, K, V> IntoIterator for &'a mut EnumMap<K, V> where
K: Enum<V>,
K: Enum<V>,
type Item = (K, &'a mut V)
The type of the elements being iterated over.
type IntoIter = IterMut<'a, K, V>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> <&'a mut EnumMap<K, V> as IntoIterator>::IntoIter
impl<K, V> PartialEq<EnumMap<K, V>> for EnumMap<K, V> where
K: Enum<V>,
V: PartialEq<V>,
K: Enum<V>,
V: PartialEq<V>,
pub fn eq(&self, other: &EnumMap<K, V>) -> bool
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<K, V> Serialize for EnumMap<K, V> where
K: Enum<V> + Serialize,
V: Serialize,
K: Enum<V> + Serialize,
V: Serialize,
Requires crate feature "serde"
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Auto Trait Implementations
impl<K, V> RefUnwindSafe for EnumMap<K, V> where
<K as Enum<V>>::Array: RefUnwindSafe,
<K as Enum<V>>::Array: RefUnwindSafe,
impl<K, V> Send for EnumMap<K, V> where
<K as Enum<V>>::Array: Send,
<K as Enum<V>>::Array: Send,
impl<K, V> Sync for EnumMap<K, V> where
<K as Enum<V>>::Array: Sync,
<K as Enum<V>>::Array: Sync,
impl<K, V> Unpin for EnumMap<K, V> where
<K as Enum<V>>::Array: Unpin,
<K as Enum<V>>::Array: Unpin,
impl<K, V> UnwindSafe for EnumMap<K, V> where
<K as Enum<V>>::Array: UnwindSafe,
<K as Enum<V>>::Array: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow(&self) -> &TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> Downcast for T where
T: Any,
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
A: Allocator + 'static,
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
A: Allocator,
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
Notable traits for Box<R, Global>
impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
A: Allocator + 'static,
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
A: Allocator,
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> DowncastSync for T where
T: Any + Send + Sync,
T: Any + Send + Sync,
impl<A> DynCastExt for A
pub fn dyn_cast<T>(
self
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source> where
T: ?Sized,
A: DynCastExtHelper<T>,
self
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source> where
T: ?Sized,
A: DynCastExtHelper<T>,
pub fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target where
T: ?Sized,
A: DynCastExtAdvHelper<T, T, Source = <A as DynCastExtAdvHelper<T, T>>::Target>,
T: ?Sized,
A: DynCastExtAdvHelper<T, T, Source = <A as DynCastExtAdvHelper<T, T>>::Target>,
pub fn dyn_cast_adv<F, T>(
self
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source> where
T: ?Sized,
A: DynCastExtAdvHelper<F, T>,
F: ?Sized,
self
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source> where
T: ?Sized,
A: DynCastExtAdvHelper<F, T>,
F: ?Sized,
pub fn dyn_cast_with_config<C>(
self
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source> where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
self
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source> where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Serialize for T where
T: Serialize + ?Sized,
[src]
T: Serialize + ?Sized,
pub fn erased_serialize(
&self,
serializer: &mut dyn Serializer
) -> Result<Ok, Error>
[src]
&self,
serializer: &mut dyn Serializer
) -> Result<Ok, Error>
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,