Struct icu::plurals::PluralOperands
source · [−]pub struct PluralOperands { /* private fields */ }
Expand description
A full plural operands representation of a number. See CLDR Plural Rules for complete operands description. Plural operands in compliance with CLDR Plural Rules.
See full operands description.
Data Types
The following types can be converted to PluralOperands
:
- Integers, signed and unsigned
- Strings representing an arbitrary-precision decimal
FixedDecimal
This crate does not support selection from a floating-point number, because floats are not
capable of carrying trailing zeros, which are required for proper plural rule selection. For
example, in English, “1 star” has a different plural form than “1.0 stars”, but this
distinction cannot be represented using a float. Clients should use FixedDecimal
instead.
Examples
From int
use icu::plurals::PluralOperands;
use icu_plurals::rules::RawPluralOperands;
assert_eq!(
PluralOperands::from(RawPluralOperands {
i: 2,
v: 0,
w: 0,
f: 0,
t: 0,
c: 0,
}),
PluralOperands::from(2_usize)
);
From &str
use icu::plurals::PluralOperands;
use icu_plurals::rules::RawPluralOperands;
assert_eq!(
Ok(PluralOperands::from(RawPluralOperands {
i: 123,
v: 2,
w: 2,
f: 45,
t: 45,
c: 0,
})),
"123.45".parse()
);
From FixedDecimal
use fixed_decimal::FixedDecimal;
use icu::plurals::PluralOperands;
use icu_plurals::rules::RawPluralOperands;
assert_eq!(
PluralOperands::from(RawPluralOperands {
i: 123,
v: 2,
w: 2,
f: 45,
t: 45,
c: 0,
}),
(&FixedDecimal::from(12345).multiplied_pow10(-2)).into()
);
Trait Implementations
sourceimpl Clone for PluralOperands
impl Clone for PluralOperands
sourcefn clone(&self) -> PluralOperands
fn clone(&self) -> PluralOperands
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for PluralOperands
impl Debug for PluralOperands
sourceimpl Default for PluralOperands
impl Default for PluralOperands
sourcefn default() -> PluralOperands
fn default() -> PluralOperands
Returns the “default value” for a type. Read more
sourceimpl<'_> From<&'_ FixedDecimal> for PluralOperands
impl<'_> From<&'_ FixedDecimal> for PluralOperands
sourcefn from(dec: &FixedDecimal) -> PluralOperands
fn from(dec: &FixedDecimal) -> PluralOperands
Converts a [fixed_decimal::FixedDecimal
] to PluralOperands
. Retains at most 18
digits each from the integer and fraction parts.
sourceimpl From<PluralOperands> for RawPluralOperands
impl From<PluralOperands> for RawPluralOperands
sourcefn from(po: PluralOperands) -> RawPluralOperands
fn from(po: PluralOperands) -> RawPluralOperands
Converts to this type from the input type.
sourceimpl From<RawPluralOperands> for PluralOperands
impl From<RawPluralOperands> for PluralOperands
sourcefn from(rpo: RawPluralOperands) -> PluralOperands
fn from(rpo: RawPluralOperands) -> PluralOperands
Converts to this type from the input type.
sourceimpl From<i128> for PluralOperands
impl From<i128> for PluralOperands
sourcefn from(input: i128) -> PluralOperands
fn from(input: i128) -> PluralOperands
Converts to this type from the input type.
sourceimpl From<i16> for PluralOperands
impl From<i16> for PluralOperands
sourcefn from(input: i16) -> PluralOperands
fn from(input: i16) -> PluralOperands
Converts to this type from the input type.
sourceimpl From<i32> for PluralOperands
impl From<i32> for PluralOperands
sourcefn from(input: i32) -> PluralOperands
fn from(input: i32) -> PluralOperands
Converts to this type from the input type.
sourceimpl From<i64> for PluralOperands
impl From<i64> for PluralOperands
sourcefn from(input: i64) -> PluralOperands
fn from(input: i64) -> PluralOperands
Converts to this type from the input type.
sourceimpl From<i8> for PluralOperands
impl From<i8> for PluralOperands
sourcefn from(input: i8) -> PluralOperands
fn from(input: i8) -> PluralOperands
Converts to this type from the input type.
sourceimpl From<isize> for PluralOperands
impl From<isize> for PluralOperands
sourcefn from(input: isize) -> PluralOperands
fn from(input: isize) -> PluralOperands
Converts to this type from the input type.
sourceimpl From<u128> for PluralOperands
impl From<u128> for PluralOperands
sourcefn from(input: u128) -> PluralOperands
fn from(input: u128) -> PluralOperands
Converts to this type from the input type.
sourceimpl From<u16> for PluralOperands
impl From<u16> for PluralOperands
sourcefn from(input: u16) -> PluralOperands
fn from(input: u16) -> PluralOperands
Converts to this type from the input type.
sourceimpl From<u32> for PluralOperands
impl From<u32> for PluralOperands
sourcefn from(input: u32) -> PluralOperands
fn from(input: u32) -> PluralOperands
Converts to this type from the input type.
sourceimpl From<u64> for PluralOperands
impl From<u64> for PluralOperands
sourcefn from(input: u64) -> PluralOperands
fn from(input: u64) -> PluralOperands
Converts to this type from the input type.
sourceimpl From<u8> for PluralOperands
impl From<u8> for PluralOperands
sourcefn from(input: u8) -> PluralOperands
fn from(input: u8) -> PluralOperands
Converts to this type from the input type.
sourceimpl From<usize> for PluralOperands
impl From<usize> for PluralOperands
sourcefn from(input: usize) -> PluralOperands
fn from(input: usize) -> PluralOperands
Converts to this type from the input type.
sourceimpl FromStr for PluralOperands
impl FromStr for PluralOperands
type Err = OperandsError
type Err = OperandsError
The associated error which can be returned from parsing.
sourcefn from_str(
input: &str
) -> Result<PluralOperands, <PluralOperands as FromStr>::Err>
fn from_str(
input: &str
) -> Result<PluralOperands, <PluralOperands as FromStr>::Err>
Parses a string s
to return a value of this type. Read more
sourceimpl PartialEq<PluralOperands> for PluralOperands
impl PartialEq<PluralOperands> for PluralOperands
sourcefn eq(&self, other: &PluralOperands) -> bool
fn eq(&self, other: &PluralOperands) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &PluralOperands) -> bool
fn ne(&self, other: &PluralOperands) -> bool
This method tests for !=
.
impl Copy for PluralOperands
impl StructuralPartialEq for PluralOperands
Auto Trait Implementations
impl RefUnwindSafe for PluralOperands
impl Send for PluralOperands
impl Sync for PluralOperands
impl Unpin for PluralOperands
impl UnwindSafe for PluralOperands
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more