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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts a fixed_decimal::FixedDecimal to PluralOperands. Retains at most 18 digits each from the integer and fraction parts.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Clone this trait object reference, returning a boxed trait object.

Return this boxed trait object as Box<dyn Any>. Read more

Return this trait object reference as &dyn Any. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.