[][src]Struct num_format::SystemLocale

pub struct SystemLocale { /* fields omitted */ }

A key type. Represents formats obtained from your operating system. Implements Format.

Example

use num_format::SystemLocale;

fn main() {
    let locale = SystemLocale::default().unwrap();
    println!("My system's default locale is...");
    println!("{:#?}", &locale);

    let available = SystemLocale::available_names().unwrap();
    println!("My available locale names are...");
    println!("{:#?}", available);

    match SystemLocale::from_name("en_US") {
        Ok(_) => println!("My system has the 'en_US' locale."),
        Err(_) => println!("The 'en_US' locale is not included with my system."),
    }
}

Methods

impl SystemLocale[src]

pub fn new() -> Result<SystemLocale, Error>[src]

Same as default.

pub fn default() -> Result<SystemLocale, Error>[src]

Constucts a SystemLocale based on your operating system's default locale.

  • Unix-based systems (including macOS): The default locale is controlled by "locale category environment variables," such as LANG, LC_MONETARY, LC_NUMERIC, and LC_ALL. For more information, see here.
  • Windows: The default locale is controlled by the regional and language options portion of the Control Panel. For more information, see here.

Errors

Returns an error if the operating system returned something unexpected (such as a null pointer).

pub fn from_name<S>(name: S) -> Result<SystemLocale, Error> where
    S: Into<String>, 
[src]

Constucts a SystemLocale from the provided locale name. For a list of locale names available on your system, see available_names.

Errors

Returns an error if the name provided could not be parsed into a SystemLocale or if the operating system returned something unexpected (such as a null pointer).

pub fn available_names() -> Result<HashSet<String>, Error>[src]

Returns a set of the locale names available on your operating system.

  • Unix-based systems (including macOS): The underlying implementation uses the locale command.
  • Windows: The underlying implementation uses the EnumSystemLocalesEx function.

Errors

Returns an error if the operating system returned something unexpected (such as a null pointer).

pub fn decimal(&self) -> &str[src]

Returns this locale's string representation of a decimal point.

pub fn grouping(&self) -> Grouping[src]

Returns this locale's Grouping, which governs how digits are separated (see Grouping).

pub fn infinity(&self) -> &str[src]

Returns this locale's string representation of infinity.

pub fn minus_sign(&self) -> &str[src]

Returns this locale's string representation of a minus sign.

pub fn name(&self) -> &str[src]

Returns this locale's name.

pub fn nan(&self) -> &str[src]

Returns this locale's string representation of NaN.

pub fn plus_sign(&self) -> &str[src]

Returns this locale's string representation of a plus sign.

pub fn separator(&self) -> &str[src]

Returns this locale's string representation of a thousands separator.

pub fn set_infinity<S>(&mut self, s: S) -> Result<(), Error> where
    S: AsRef<str>, 
[src]

Unix-based operating systems (including macOS) do not provide information on how to represent infinity symbols; so num-format uses "∞" (U+221E) as a default. This method allows you to change that default.

Errors

Returns an error the provided string is longer than 128 bytes.

pub fn set_nan<S>(&mut self, s: S) -> Result<(), Error> where
    S: AsRef<str>, 
[src]

Unix-based operating systems (including macOS) do not provide information on how to represent NaN; so num-format uses "NaN" as a default. This method allows you to change that default.

Errors

Returns an error the provided string is longer than 64 bytes.

Trait Implementations

impl Format for SystemLocale[src]

impl Clone for SystemLocale[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl From<SystemLocale> for CustomFormat[src]

impl From<SystemLocale> for CustomFormatBuilder[src]

impl Eq for SystemLocale[src]

impl PartialEq<SystemLocale> for SystemLocale[src]

impl Debug for SystemLocale[src]

impl FromStr for SystemLocale[src]

type Err = Error

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<Self, Self::Err>[src]

Same as from_name.

impl Hash for SystemLocale[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> From for T[src]

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

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

type Owned = T

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

type Error = !

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

The type returned in the event of a conversion error.

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

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

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

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

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

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

The type returned in the event of a conversion error.