[−][src]Struct address_formatter::Place
A Place
is a structured way to represent a postal address.
Note: it is internally represented as an EnumMap to easily loop over all the fields
Methods from Deref<Target = EnumMap<Component, Option<String>>>
pub fn values(&self) -> Values<V>
An iterator visiting all values. The iterator type is &V
.
Examples
use enum_map::enum_map; fn main() { 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; fn main() { let mut map = enum_map! { _ => 2 }; for value in map.values_mut() { *value += 2; } assert_eq!(map[false], 4); assert_eq!(map[true], 4); }
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 is_empty(&self) -> bool
Returns whether the enum variant set is empty.
This isn't particularly useful, as there is no real reason to use enum map for enums without variants. However, it is provided for consistency with data structures providing len method (and I will admit, to avoid clippy warnings).
Examples
use enum_map::{Enum, EnumMap}; #[derive(Enum)] enum Void {} #[derive(Enum)] enum SingleVariant { Variant, } fn main() { assert!(EnumMap::<Void, ()>::new().is_empty()); assert!(!EnumMap::<SingleVariant, ()>::new().is_empty()); }
pub fn swap(&mut self, a: K, b: K)
Swaps two indexes.
Examples
use enum_map::enum_map; fn main() { 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.
pub fn as_ptr(&self) -> *const V
Returns a raw pointer to the enum map's slice.
The caller must ensure that the slice outlives the pointer this function returns, or else it will end up pointing to garbage.
Examples
use enum_map::{enum_map, EnumMap}; fn main() { let map = enum_map! { 5 => 42, _ => 0 }; assert_eq!(unsafe { *map.as_ptr().offset(5) }, 42); }
pub fn as_mut_ptr(&mut self) -> *mut V
Returns an unsafe mutable pointer to the enum map's slice.
The caller must ensure that the slice outlives the pointer this function returns, or else it will end up pointing to garbage.
Examples
use enum_map::{enum_map, EnumMap}; fn main() { let mut map = enum_map! { _ => 0 }; unsafe { *map.as_mut_ptr().offset(11) = 23 }; assert_eq!(map[11], 23); }
Trait Implementations
impl Default for Place
[src]
impl<'a, T> From<T> for Place where
T: IntoIterator<Item = (Component, &'a str)>,
[src]
T: IntoIterator<Item = (Component, &'a str)>,
impl Debug for Place
[src]
impl DerefMut for Place
[src]
impl Deref for Place
[src]
type Target = EnumMap<Component, Option<String>>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl Serialize for Place
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto 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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,