[−][src]Struct num_format::SystemLocale
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
, andLC_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]
S: Into<String>,
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]
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]
S: AsRef<str>,
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]
S: AsRef<str>,
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]
fn decimal(&self) -> DecimalStr
[src]
fn grouping(&self) -> Grouping
[src]
fn infinity(&self) -> InfinityStr
[src]
fn minus_sign(&self) -> MinusSignStr
[src]
fn nan(&self) -> NanStr
[src]
fn plus_sign(&self) -> PlusSignStr
[src]
fn separator(&self) -> SeparatorStr
[src]
impl Clone for SystemLocale
[src]
fn clone(&self) -> 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]
fn from(locale: SystemLocale) -> Self
[src]
impl From<SystemLocale> for CustomFormatBuilder
[src]
fn from(locale: SystemLocale) -> Self
[src]
impl Eq for SystemLocale
[src]
impl PartialEq<SystemLocale> for SystemLocale
[src]
fn eq(&self, other: &SystemLocale) -> bool
[src]
fn ne(&self, other: &SystemLocale) -> bool
[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]
Auto Trait Implementations
impl Send for SystemLocale
impl Sync for SystemLocale
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,