pub struct LangMap<V> { /* private fields */ }
Expand description
Represents a map of Lang
keys that can be partially matched.
Implementations§
source§impl<V> LangMap<V>
impl<V> LangMap<V>
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
New empty with pre-allocated capacity.
sourcepub fn best_match(&self, lang: &Lang) -> Option<&Lang>
pub fn best_match(&self, lang: &Lang) -> Option<&Lang>
Returns the best match to lang
currently in the map.
sourcepub fn get_exact_mut(&mut self, lang: &Lang) -> Option<&mut V>
pub fn get_exact_mut(&mut self, lang: &Lang) -> Option<&mut V>
Returns the exact match for lang
.
sourcepub fn get_exact_or_insert(
&mut self,
lang: Lang,
new: impl FnOnce() -> V,
) -> &mut V
pub fn get_exact_or_insert( &mut self, lang: Lang, new: impl FnOnce() -> V, ) -> &mut V
Returns the current value or insert new
and return a reference to it.
sourcepub fn insert(&mut self, lang: Lang, value: V) -> Option<V>
pub fn insert(&mut self, lang: Lang, value: V) -> Option<V>
Insert the value with the exact match of lang
.
Returns the previous exact match.
sourcepub fn remove_all(&mut self, lang: &Lang) -> usize
pub fn remove_all(&mut self, lang: &Lang) -> usize
Remove all exact and partial matches of lang
.
Returns a count of items removed.
sourcepub fn keys(&self) -> impl ExactSizeIterator<Item = &Lang>
pub fn keys(&self) -> impl ExactSizeIterator<Item = &Lang>
Iterator over lang keys.
sourcepub fn values(&self) -> impl ExactSizeIterator<Item = &V>
pub fn values(&self) -> impl ExactSizeIterator<Item = &V>
Iterator over values.
sourcepub fn values_mut(&mut self) -> impl ExactSizeIterator<Item = &mut V>
pub fn values_mut(&mut self) -> impl ExactSizeIterator<Item = &mut V>
Iterator over values.
sourcepub fn into_values(self) -> impl ExactSizeIterator<Item = V>
pub fn into_values(self) -> impl ExactSizeIterator<Item = V>
Into iterator of values.
sourcepub fn iter(&self) -> impl ExactSizeIterator<Item = (&Lang, &V)>
pub fn iter(&self) -> impl ExactSizeIterator<Item = (&Lang, &V)>
Iterate over key-value pairs.
sourcepub fn iter_mut(&mut self) -> impl ExactSizeIterator<Item = (&Lang, &mut V)>
pub fn iter_mut(&mut self) -> impl ExactSizeIterator<Item = (&Lang, &mut V)>
Iterate over key-value pairs with mutable values.
source§impl<V> LangMap<HashMap<LangFilePath, V>>
impl<V> LangMap<HashMap<LangFilePath, V>>
sourcepub fn get_file(&self, lang: &Lang, file: &LangFilePath) -> Option<&V>
pub fn get_file(&self, lang: &Lang, file: &LangFilePath) -> Option<&V>
Returns the match for lang
and file
.
sourcepub fn best_file_match(
&self,
lang: &Lang,
file: &LangFilePath,
) -> Option<&LangFilePath>
pub fn best_file_match( &self, lang: &Lang, file: &LangFilePath, ) -> Option<&LangFilePath>
Returns the best match to lang
and file
currently in the map.
Trait Implementations§
source§impl<'de, V> Deserialize<'de> for LangMap<V>where
V: Deserialize<'de>,
impl<'de, V> Deserialize<'de> for LangMap<V>where
V: Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<V> IntoIterator for LangMap<V>
impl<V> IntoIterator for LangMap<V>
impl<V: Eq> Eq for LangMap<V>
Auto Trait Implementations§
impl<V> Freeze for LangMap<V>
impl<V> RefUnwindSafe for LangMap<V>where
V: RefUnwindSafe,
impl<V> Send for LangMap<V>where
V: Send,
impl<V> Sync for LangMap<V>where
V: Sync,
impl<V> Unpin for LangMap<V>where
V: Unpin,
impl<V> UnwindSafe for LangMap<V>where
V: UnwindSafe,
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
source§impl<T> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Access to mut
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
Clone the value.
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
Clone the value into a new boxed
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
Gets if
self
equals other
.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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§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>
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