Struct icu_plurals::PluralElements
source · pub struct PluralElements<T>(/* private fields */);
Expand description
A bag of values for different plural cases.
Implementations§
source§impl<T> PluralElements<T>
impl<T> PluralElements<T>
sourcepub fn new(other: T) -> Self
pub fn new(other: T) -> Self
Creates a new PluralElements
with the given default value.
sourcepub fn zero(&self) -> &T
pub fn zero(&self) -> &T
The value for PluralCategory::Zero
sourcepub fn one(&self) -> &T
pub fn one(&self) -> &T
The value for PluralCategory::One
sourcepub fn two(&self) -> &T
pub fn two(&self) -> &T
The value for PluralCategory::Two
sourcepub fn few(&self) -> &T
pub fn few(&self) -> &T
The value for PluralCategory::Few
sourcepub fn many(&self) -> &T
pub fn many(&self) -> &T
The value for PluralCategory::Many
sourcepub fn other(&self) -> &T
pub fn other(&self) -> &T
The value for PluralCategory::Other
sourcepub fn explicit_zero(&self) -> Option<&T>
pub fn explicit_zero(&self) -> Option<&T>
The value used when the PluralOperands
are exactly 0.
sourcepub fn explicit_one(&self) -> Option<&T>
pub fn explicit_one(&self) -> Option<&T>
The value used when the PluralOperands
are exactly 1.
sourcepub fn map<B, F: Fn(T) -> B>(self, f: F) -> PluralElements<B>
pub fn map<B, F: Fn(T) -> B>(self, f: F) -> PluralElements<B>
Applies a function f
to map all values to another type.
source§impl<T: PartialEq> PluralElements<T>
impl<T: PartialEq> PluralElements<T>
sourcepub fn with_zero_value(self, zero: Option<T>) -> Self
pub fn with_zero_value(self, zero: Option<T>) -> Self
Sets the value for PluralCategory::Zero
.
sourcepub fn with_one_value(self, one: Option<T>) -> Self
pub fn with_one_value(self, one: Option<T>) -> Self
Sets the value for PluralCategory::One
.
sourcepub fn with_two_value(self, two: Option<T>) -> Self
pub fn with_two_value(self, two: Option<T>) -> Self
Sets the value for PluralCategory::Two
.
sourcepub fn with_few_value(self, few: Option<T>) -> Self
pub fn with_few_value(self, few: Option<T>) -> Self
Sets the value for PluralCategory::Few
.
sourcepub fn with_many_value(self, many: Option<T>) -> Self
pub fn with_many_value(self, many: Option<T>) -> Self
Sets the value for PluralCategory::Many
.
sourcepub fn with_explicit_zero_value(self, explicit_zero: Option<T>) -> Self
pub fn with_explicit_zero_value(self, explicit_zero: Option<T>) -> Self
Sets the value for explicit 0.
sourcepub fn with_explicit_one_value(self, explicit_one: Option<T>) -> Self
pub fn with_explicit_one_value(self, explicit_one: Option<T>) -> Self
Sets the value for explicit 1.
Trait Implementations§
source§impl<T: Debug> Debug for PluralElements<T>
impl<T: Debug> Debug for PluralElements<T>
source§impl<T, V> EncodeAsVarULE<PluralElementsPackedULE<V>> for PluralElements<(FourBitMetadata, T)>
impl<T, V> EncodeAsVarULE<PluralElementsPackedULE<V>> for PluralElements<(FourBitMetadata, T)>
source§fn encode_var_ule_as_slices<R>(&self, _cb: impl FnOnce(&[&[u8]]) -> R) -> R
fn encode_var_ule_as_slices<R>(&self, _cb: impl FnOnce(&[&[u8]]) -> R) -> R
Calls
cb
with a piecewise list of byte slices that when concatenated
produce the memory pattern of the corresponding instance of T
. Read moresource§fn encode_var_ule_len(&self) -> usize
fn encode_var_ule_len(&self) -> usize
Return the length, in bytes, of the corresponding [
VarULE
] typesource§fn encode_var_ule_write(&self, dst: &mut [u8])
fn encode_var_ule_write(&self, dst: &mut [u8])
Write the corresponding [
VarULE
] type to the dst
buffer. dst
should
be the size of [Self::encode_var_ule_len()
]source§impl<T, V> From<PluralElements<T>> for PluralElementsPackedCow<'static, V>
impl<T, V> From<PluralElements<T>> for PluralElementsPackedCow<'static, V>
source§fn from(value: PluralElements<T>) -> Self
fn from(value: PluralElements<T>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<T> Freeze for PluralElements<T>where
T: Freeze,
impl<T> RefUnwindSafe for PluralElements<T>where
T: RefUnwindSafe,
impl<T> Send for PluralElements<T>where
T: Send,
impl<T> Sync for PluralElements<T>where
T: Sync,
impl<T> Unpin for PluralElements<T>where
T: Unpin,
impl<T> UnwindSafe for PluralElements<T>where
T: UnwindSafe,
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