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>

source

pub fn new(other: T) -> Self

Creates a new PluralElements with the given default value.

source

pub fn zero(&self) -> &T

The value for PluralCategory::Zero

source

pub fn one(&self) -> &T

The value for PluralCategory::One

source

pub fn two(&self) -> &T

The value for PluralCategory::Two

source

pub fn few(&self) -> &T

The value for PluralCategory::Few

source

pub fn many(&self) -> &T

The value for PluralCategory::Many

source

pub fn other(&self) -> &T

The value for PluralCategory::Other

source

pub fn explicit_zero(&self) -> Option<&T>

The value used when the PluralOperands are exactly 0.

source

pub fn explicit_one(&self) -> Option<&T>

The value used when the PluralOperands are exactly 1.

source

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>

source

pub fn with_zero_value(self, zero: Option<T>) -> Self

Sets the value for PluralCategory::Zero.

source

pub fn with_one_value(self, one: Option<T>) -> Self

Sets the value for PluralCategory::One.

source

pub fn with_two_value(self, two: Option<T>) -> Self

Sets the value for PluralCategory::Two.

source

pub fn with_few_value(self, few: Option<T>) -> Self

Sets the value for PluralCategory::Few.

source

pub fn with_many_value(self, many: Option<T>) -> Self

Sets the value for PluralCategory::Many.

source

pub fn with_explicit_zero_value(self, explicit_zero: Option<T>) -> Self

Sets the value for explicit 0.

source

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>

source§

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

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

impl<T, V> EncodeAsVarULE<PluralElementsPackedULE<V>> for PluralElements<(FourBitMetadata, T)>
where T: PartialEq + Debug, for<'a> &'a T: EncodeAsVarULE<V>, V: VarULE + ?Sized,

source§

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

fn encode_var_ule_len(&self) -> usize

Return the length, in bytes, of the corresponding [VarULE] type
source§

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>
where V: VarULE + ?Sized, T: PartialEq + Debug, for<'a> &'a T: EncodeAsVarULE<V>,

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,