pub struct LocaleMap(pub GenericHashMap<LanguageIdentifier, Rc<FluentBundle<FluentResource, IntlLangMemoizer>>, RandomState, ArcK>);Expand description
A map that stores localizations.
Tuple Fields§
§0: GenericHashMap<LanguageIdentifier, Rc<FluentBundle<FluentResource, IntlLangMemoizer>>, RandomState, ArcK>Implementations§
Source§impl LocaleMap
impl LocaleMap
Sourcepub fn from_resources<'a, I>(resources: I) -> Result<LocaleMap, Box<dyn Error>>
pub fn from_resources<'a, I>(resources: I) -> Result<LocaleMap, Box<dyn Error>>
Accepts list of the language resources in a form of a list implementing IntoIterator containing tuple of (<language_name>, <localization_file>) string slices.
§Example
let locales = LocaleMap::from_resources([
("en-US", include_str!("../../examples/localization/locales/en-US/app.ftl")),
("pl-PL", include_str!("../../examples/localization/locales/pl-PL/app.ftl"))
]);Methods from Deref<Target = GenericHashMap<LanguageIdentifier, Rc<FluentBundle<FluentResource, IntlLangMemoizer>>, RandomState, ArcK>>§
pub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Test whether a hash map is empty.
Time: O(1)
§Examples
assert!(
!hashmap!{1 => 2}.is_empty()
);
assert!(
HashMap::<i32, i32>::new().is_empty()
);pub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the size of a hash map.
Time: O(1)
§Examples
assert_eq!(3, hashmap!{
1 => 11,
2 => 22,
3 => 33
}.len());pub fn ptr_eq(&self, other: &GenericHashMap<K, V, S, P>) -> bool
pub fn ptr_eq(&self, other: &GenericHashMap<K, V, S, P>) -> bool
Test whether two maps refer to the same content in memory.
This is true if the two sides are references to the same map, or if the two maps refer to the same root node.
This would return true if you’re comparing a map to itself, or if you’re comparing a map to a fresh clone of itself.
Time: O(1)
pub fn hasher(&self) -> &S
pub fn hasher(&self) -> &S
Get a reference to the map’s BuildHasher.
pub fn new_from<K1, V1>(&self) -> GenericHashMap<K1, V1, S, P>
pub fn new_from<K1, V1>(&self) -> GenericHashMap<K1, V1, S, P>
Construct an empty hash map using the same hasher as the current hash map.
pub fn iter(&self) -> Iter<'_, K, V, P>
pub fn iter(&self) -> Iter<'_, K, V, P>
Get an iterator over the key/value pairs of a hash map.
Please note that the order is consistent between maps using the same hasher, but no other ordering guarantee is offered. Items will not come out in insertion order or sort order. They will, however, come out in the same order every time for the same map.
pub fn keys(&self) -> Keys<'_, K, V, P>
pub fn keys(&self) -> Keys<'_, K, V, P>
Get an iterator over a hash map’s keys.
Please note that the order is consistent between maps using the same hasher, but no other ordering guarantee is offered. Items will not come out in insertion order or sort order. They will, however, come out in the same order every time for the same map.
pub fn values(&self) -> Values<'_, K, V, P>
pub fn values(&self) -> Values<'_, K, V, P>
Get an iterator over a hash map’s values.
Please note that the order is consistent between maps using the same hasher, but no other ordering guarantee is offered. Items will not come out in insertion order or sort order. They will, however, come out in the same order every time for the same map.
pub fn clear(&mut self)
pub fn clear(&mut self)
Discard all elements from the map.
This leaves you with an empty map, and all elements that were previously inside it are dropped.
Time: O(n)
§Examples
let mut map = hashmap![1=>1, 2=>2, 3=>3];
map.clear();
assert!(map.is_empty());pub fn get<BK>(&self, key: &BK) -> Option<&V>
pub fn get<BK>(&self, key: &BK) -> Option<&V>
Get the value for a key from a hash map.
Time: O(log n)
§Examples
let map = hashmap!{123 => "lol"};
assert_eq!(
map.get(&123),
Some(&"lol")
);pub fn get_key_value<BK>(&self, key: &BK) -> Option<(&K, &V)>
pub fn get_key_value<BK>(&self, key: &BK) -> Option<(&K, &V)>
Get the key/value pair for a key from a hash map.
Time: O(log n)
§Examples
let map = hashmap!{123 => "lol"};
assert_eq!(
map.get_key_value(&123),
Some((&123, &"lol"))
);pub fn contains_key<BK>(&self, k: &BK) -> bool
pub fn contains_key<BK>(&self, k: &BK) -> bool
Test for the presence of a key in a hash map.
Time: O(log n)
§Examples
let map = hashmap!{123 => "lol"};
assert!(
map.contains_key(&123)
);
assert!(
!map.contains_key(&321)
);pub fn is_submap_by<B, RM, F, P2>(&self, other: RM, cmp: F) -> bool
pub fn is_submap_by<B, RM, F, P2>(&self, other: RM, cmp: F) -> bool
Test whether a map is a submap of another map, meaning that all keys in our map must also be in the other map, with the same values.
Use the provided function to decide whether values are equal.
Time: O(n log n)
pub fn is_proper_submap_by<B, RM, F, P2>(&self, other: RM, cmp: F) -> bool
pub fn is_proper_submap_by<B, RM, F, P2>(&self, other: RM, cmp: F) -> bool
Test whether a map is a proper submap of another map, meaning that all keys in our map must also be in the other map, with the same values. To be a proper submap, ours must also contain fewer keys than the other map.
Use the provided function to decide whether values are equal.
Time: O(n log n)
pub fn is_submap<RM>(&self, other: RM) -> bool
pub fn is_submap<RM>(&self, other: RM) -> bool
Test whether a map is a submap of another map, meaning that all keys in our map must also be in the other map, with the same values.
Time: O(n log n)
§Examples
let map1 = hashmap!{1 => 1, 2 => 2};
let map2 = hashmap!{1 => 1, 2 => 2, 3 => 3};
assert!(map1.is_submap(map2));pub fn is_proper_submap<RM>(&self, other: RM) -> bool
pub fn is_proper_submap<RM>(&self, other: RM) -> bool
Test whether a map is a proper submap of another map, meaning that all keys in our map must also be in the other map, with the same values. To be a proper submap, ours must also contain fewer keys than the other map.
Time: O(n log n)
§Examples
let map1 = hashmap!{1 => 1, 2 => 2};
let map2 = hashmap!{1 => 1, 2 => 2, 3 => 3};
assert!(map1.is_proper_submap(map2));
let map3 = hashmap!{1 => 1, 2 => 2};
let map4 = hashmap!{1 => 1, 2 => 2};
assert!(!map3.is_proper_submap(map4));pub fn iter_mut(&mut self) -> IterMut<'_, K, V, P>
pub fn iter_mut(&mut self) -> IterMut<'_, K, V, P>
Get a mutable iterator over the values of a hash map.
Please note that the order is consistent between maps using the same hasher, but no other ordering guarantee is offered. Items will not come out in insertion order or sort order. They will, however, come out in the same order every time for the same map.
pub fn get_mut<BK>(&mut self, key: &BK) -> Option<&mut V>
pub fn get_mut<BK>(&mut self, key: &BK) -> Option<&mut V>
Get a mutable reference to the value for a key from a hash map.
Time: O(log n)
§Examples
let mut map = hashmap!{123 => "lol"};
if let Some(value) = map.get_mut(&123) {
*value = "omg";
}
assert_eq!(
map.get(&123),
Some(&"omg")
);pub fn get_key_value_mut<BK>(&mut self, key: &BK) -> Option<(&K, &mut V)>
pub fn get_key_value_mut<BK>(&mut self, key: &BK) -> Option<(&K, &mut V)>
Get the key/value pair for a key from a hash map, returning a mutable reference to the value.
Time: O(log n)
§Examples
let mut map = hashmap!{123 => "lol"};
assert_eq!(
map.get_key_value_mut(&123),
Some((&123, &mut "lol"))
);pub fn insert(&mut self, k: K, v: V) -> Option<V>
pub fn insert(&mut self, k: K, v: V) -> Option<V>
Insert a key/value mapping into a map.
If the map already has a mapping for the given key, the previous value is overwritten.
Time: O(log n)
§Examples
let mut map = hashmap!{};
map.insert(123, "123");
map.insert(456, "456");
assert_eq!(
map,
hashmap!{123 => "123", 456 => "456"}
);pub fn remove<BK>(&mut self, k: &BK) -> Option<V>
pub fn remove<BK>(&mut self, k: &BK) -> Option<V>
Remove a key/value pair from a map, if it exists, and return the removed value.
This is a copy-on-write operation, so that the parts of the set’s structure which are shared with other sets will be safely copied before mutating.
Time: O(log n)
§Examples
let mut map = hashmap!{123 => "123", 456 => "456"};
assert_eq!(Some("123"), map.remove(&123));
assert_eq!(Some("456"), map.remove(&456));
assert_eq!(None, map.remove(&789));
assert!(map.is_empty());pub fn remove_with_key<BK>(&mut self, k: &BK) -> Option<(K, V)>
pub fn remove_with_key<BK>(&mut self, k: &BK) -> Option<(K, V)>
Remove a key/value pair from a map, if it exists, and return the removed key and value.
Time: O(log n)
§Examples
let mut map = hashmap!{123 => "123", 456 => "456"};
assert_eq!(Some((123, "123")), map.remove_with_key(&123));
assert_eq!(Some((456, "456")), map.remove_with_key(&456));
assert_eq!(None, map.remove_with_key(&789));
assert!(map.is_empty());pub fn entry(&mut self, key: K) -> Entry<'_, K, V, S, P>
pub fn entry(&mut self, key: K) -> Entry<'_, K, V, S, P>
Get the Entry for a key in the map for in-place manipulation.
Time: O(log n)
pub fn update(&self, k: K, v: V) -> GenericHashMap<K, V, S, P>
pub fn update(&self, k: K, v: V) -> GenericHashMap<K, V, S, P>
Construct a new hash map by inserting a key/value mapping into a map.
If the map already has a mapping for the given key, the previous value is overwritten.
Time: O(log n)
§Examples
let map = hashmap!{};
assert_eq!(
map.update(123, "123"),
hashmap!{123 => "123"}
);pub fn update_with<F>(&self, k: K, v: V, f: F) -> GenericHashMap<K, V, S, P>where
F: FnOnce(V, V) -> V,
pub fn update_with<F>(&self, k: K, v: V, f: F) -> GenericHashMap<K, V, S, P>where
F: FnOnce(V, V) -> V,
Construct a new hash map by inserting a key/value mapping into a map.
If the map already has a mapping for the given key, we call the provided function with the old value and the new value, and insert the result as the new value.
Time: O(log n)
pub fn update_with_key<F>(&self, k: K, v: V, f: F) -> GenericHashMap<K, V, S, P>
pub fn update_with_key<F>(&self, k: K, v: V, f: F) -> GenericHashMap<K, V, S, P>
Construct a new map by inserting a key/value mapping into a map.
If the map already has a mapping for the given key, we call the provided function with the key, the old value and the new value, and insert the result as the new value.
Time: O(log n)
pub fn update_lookup_with_key<F>(
&self,
k: K,
v: V,
f: F,
) -> (Option<V>, GenericHashMap<K, V, S, P>)
pub fn update_lookup_with_key<F>( &self, k: K, v: V, f: F, ) -> (Option<V>, GenericHashMap<K, V, S, P>)
Construct a new map by inserting a key/value mapping into a map, returning the old value for the key as well as the new map.
If the map already has a mapping for the given key, we call the provided function with the key, the old value and the new value, and insert the result as the new value.
Time: O(log n)
pub fn alter<F>(&self, f: F, k: K) -> GenericHashMap<K, V, S, P>
pub fn alter<F>(&self, f: F, k: K) -> GenericHashMap<K, V, S, P>
Update the value for a given key by calling a function with the current value and overwriting it with the function’s return value.
The function gets an Option<V> and
returns the same, so that it can decide to delete a mapping
instead of updating the value, and decide what to do if the
key isn’t in the map.
Time: O(log n)
pub fn without<BK>(&self, k: &BK) -> GenericHashMap<K, V, S, P>
pub fn without<BK>(&self, k: &BK) -> GenericHashMap<K, V, S, P>
Construct a new map without the given key.
Construct a map that’s a copy of the current map, absent the
mapping for key if it’s present.
Time: O(log n)
pub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Filter out values from a map which don’t satisfy a predicate.
This is slightly more efficient than filtering using an iterator, in that it doesn’t need to rehash the retained values, but it still needs to reconstruct the entire tree structure of the map.
Time: O(n log n)
§Examples
let mut map = hashmap!{1 => 1, 2 => 2, 3 => 3};
map.retain(|k, v| *k > 1);
let expected = hashmap!{2 => 2, 3 => 3};
assert_eq!(expected, map);Trait Implementations§
Source§impl StylePropValue for LocaleMap
impl StylePropValue for LocaleMap
Auto Trait Implementations§
impl Freeze for LocaleMap
impl !RefUnwindSafe for LocaleMap
impl !Send for LocaleMap
impl !Sync for LocaleMap
impl Unpin for LocaleMap
impl UnsafeUnpin for LocaleMap
impl !UnwindSafe for LocaleMap
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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