zng_ext_l10n

Struct LangMap

source
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>

source

pub fn new() -> Self

New empty default.

source

pub fn with_capacity(capacity: usize) -> Self

New empty with pre-allocated capacity.

source

pub fn best_match(&self, lang: &Lang) -> Option<&Lang>

Returns the best match to lang currently in the map.

source

pub fn get(&self, lang: &Lang) -> Option<&V>

Returns the best match for lang.

source

pub fn get_exact(&self, lang: &Lang) -> Option<&V>

Returns the exact match for lang.

source

pub fn get_mut(&mut self, lang: &Lang) -> Option<&mut V>

Returns the best match for lang.

source

pub fn get_exact_mut(&mut self, lang: &Lang) -> Option<&mut V>

Returns the exact match for lang.

source

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.

source

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.

source

pub fn remove(&mut self, lang: &Lang) -> Option<V>

Remove the exact match of lang.

source

pub fn remove_all(&mut self, lang: &Lang) -> usize

Remove all exact and partial matches of lang.

Returns a count of items removed.

source

pub fn pop(&mut self) -> Option<(Lang, V)>

Remove the last inserted lang.

source

pub fn is_empty(&self) -> bool

Returns if the map is empty.

source

pub fn len(&self) -> usize

Returns the number of languages in the map.

source

pub fn clear(&mut self)

Remove all entries.

source

pub fn keys(&self) -> impl ExactSizeIterator<Item = &Lang>

Iterator over lang keys.

source

pub fn values(&self) -> impl ExactSizeIterator<Item = &V>

Iterator over values.

source

pub fn values_mut(&mut self) -> impl ExactSizeIterator<Item = &mut V>

Iterator over values.

source

pub fn into_values(self) -> impl ExactSizeIterator<Item = V>

Into iterator of values.

source

pub fn iter(&self) -> impl ExactSizeIterator<Item = (&Lang, &V)>

Iterate over key-value pairs.

source

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>>

source

pub fn get_file(&self, lang: &Lang, file: &LangFilePath) -> Option<&V>

Returns the match for lang and file.

source

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<V: Clone> Clone for LangMap<V>

source§

fn clone(&self) -> LangMap<V>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<V: Debug> Debug for LangMap<V>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<V> Default for LangMap<V>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<V> IntoIterator for LangMap<V>

source§

type Item = (Lang, V)

The type of the elements being iterated over.
source§

type IntoIter = IntoIter<(Lang, V)>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<V: PartialEq> PartialEq for LangMap<V>

source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<V> Serialize for LangMap<V>
where V: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

source§

impl<T> AnyVarValue for T
where T: VarValue,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Access to dyn Any methods.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Access to mut dyn Any methods.
source§

fn clone_boxed(&self) -> Box<dyn AnyVarValue>

Clone the value.
source§

fn clone_boxed_var(&self) -> Box<dyn AnyVar>

Clone the value into a new boxed LocalVar<Self>.
source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Access to Box<dyn Any> methods.
source§

fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool

Gets if self equals other.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FsChangeNote for T
where T: Debug + Any + Send + Sync,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Access any.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> IntoVar<T> for T
where T: VarValue,

source§

type Var = LocalVar<T>

Variable type that will wrap the T value. Read more
source§

fn into_var(self) -> <T as IntoVar<T>>::Var

Converts the source value into a var.
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> IntoValue<T> for T
where T: VarValue,

source§

impl<T> IpcValue for T
where T: Debug + Serialize + for<'d> Deserialize<'d> + Send + 'static,

source§

impl<T> StateValue for T
where T: Any + Send + Sync,

source§

impl<T> VarValue for T
where T: Debug + Clone + PartialEq + Any + Send + Sync,