Struct icu_plurals::PluralOperands [−][src]
pub struct PluralOperands { pub i: u64, pub v: usize, pub w: usize, pub f: u64, pub t: u64, pub c: usize, }
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; assert_eq!(PluralOperands { i: 2, v: 0, w: 0, f: 0, t: 0, c: 0, }, PluralOperands::from(2_usize))
From &str
use icu::plurals::PluralOperands; assert_eq!(Ok(PluralOperands { 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; assert_eq!(Ok(PluralOperands { i: 123, v: 2, w: 2, f: 45, t: 45, c: 0, }), FixedDecimal::from(12345).multiplied_pow10(-2).map(|d| (&d).into()))
Fields
i: u64
Integer value of input
v: usize
Number of visible fraction digits with trailing zeros
w: usize
Number of visible fraction digits without trailing zeros
f: u64
Visible fraction digits with trailing zeros
t: u64
Visible fraction digits without trailing zeros
c: usize
Exponent of the power of 10 used in compact decimal formatting
Implementations
Returns the number represented by this PluralOperands
as floating point.
The precision of the number returned is up to the representation accuracy
of a double.
This method requires the "std"
feature be enabled
Trait Implementations
Converts a fixed_decimal::FixedDecimal
to PluralOperands
. Retains at most 18
digits each from the integer and fraction parts.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
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
Mutably borrows from an owned value. Read more
Clone this trait object reference, returning a boxed trait object.