Enum icu::decimal::options::SignDisplay[][src]

#[non_exhaustive]
pub enum SignDisplay {
    Auto,
    Never,
    Always,
    ExceptZero,
    Negative,
}

Configuration for when to render the minus sign or plus sign.

Examples

use icu_decimal::FixedDecimalFormat;
use icu_decimal::FormattedFixedDecimal;
use icu_decimal::options;
use icu_locid::Locale;
use writeable::Writeable;

let locale: Locale = Locale::und().into();
let provider = icu_provider::inv::InvariantDataProvider;
let mut options: options::FixedDecimalFormatOptions = Default::default();
options.sign_display = options::SignDisplay::ExceptZero;
let fdf = FixedDecimalFormat::try_new(locale, &provider, options)
    .expect("Data should load successfully");

let pos_thousand = 1000.into();
assert_eq!("+1,000", fdf.format(&pos_thousand).writeable_to_string());

let zero = 0.into();
assert_eq!("0", fdf.format(&zero).writeable_to_string());

let neg_thousand = (-1000).into();
assert_eq!("-1,000", fdf.format(&neg_thousand).writeable_to_string());

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Auto

Render the sign according to locale preferences. In most cases, this means a minus sign will be shown on negative numbers, and no sign will be shown on positive numbers.

Never

Do not display the sign. Positive and negative numbers are indistinguishable.

Always

Show a minus sign on negative numbers and a plus sign on positive numbers, including zero.

ExceptZero

Show a minus sign on negative numbers and a plus sign on positive numbers, except do not show any sign on positive or negative zero.

Negative

Show a minus sign on strictly negative numbers. Do not show a sign on positive numbers or on positive or negative zero.

This differs from Auto in that it does not render a sign on negative zero.

Trait Implementations

impl Clone for SignDisplay[src]

impl Copy for SignDisplay[src]

impl Debug for SignDisplay[src]

impl Default for SignDisplay[src]

impl Eq for SignDisplay[src]

impl PartialEq<SignDisplay> for SignDisplay[src]

impl StructuralEq for SignDisplay[src]

impl StructuralPartialEq for SignDisplay[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> ErasedDataStruct for T where
    T: Clone + Debug + Any

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.