pub struct Place(/* private fields */);Expand description
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>>>§
Sourcepub fn values(&self) -> Values<'_, 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);Sourcepub fn values_mut(&mut self) -> ValuesMut<'_, V>
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);Sourcepub fn clear(&mut self)
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], "");Sourcepub fn swap(&mut self, a: K, b: K)
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);Sourcepub fn as_mut_slice(&mut self) -> &mut [V]
pub fn as_mut_slice(&mut self) -> &mut [V]
Converts a mutable enum map to a mutable slice representing values.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Place
impl RefUnwindSafe for Place
impl Send for Place
impl Sync for Place
impl Unpin for Place
impl UnwindSafe for Place
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more