[−][src]Struct num_format::format::Environment
Type for representing formats from the LC_ALL environment variable.
Example
use std::env; use failure; use num_format::{format::Environment, ToFormattedString}; fn main() -> Result<(), failure::Error> { // Use your system's default locale settings let format = Environment::new()?; let s = (-1000000).to_formatted_string(&format); println!("{}", &s); // Use your system's locale settings for "en_US.UTF-8" env::set_var("LC_ALL", "en_US.UTF-8"); let format = Environment::new()?; let s = (-1000000).to_formatted_string(&format); assert_eq!("-1,000,000", &s); Ok(()) }
Methods
impl Environment[src]
pub fn new() -> Result<Environment, Error>[src]
Constructs a new Environment.
Note
- This method uses the
setlocaleandlocaleconvAPI from C in order to access your system's locale settings specified by theLC_ALLenvironment variable. - Because representations of infinity and NaN are not specified in locale files,
English representations from the Unicode Common Locale Data Repository (CLDR)
are used for these values, which are
"∞"(U+221E) and"NaN". You can change these with calls to theset_infinityandset_nanmethods.
Errors
Return an error if any of the calls into C fail (e.g. if localeconv return a NULL pointer).
pub fn decimal(&self) -> char[src]
Returns this format's representation of decimal points.
pub fn grouping(&self) -> Grouping[src]
pub fn infinity(&self) -> &str[src]
Returns this format's representation of infinity.
pub fn minus_sign(&self) -> &str[src]
Returns this format's representation of minus signs.
pub fn nan(&self) -> &str[src]
Returns this format's representation of NaN.
pub fn separator(&self) -> Option<char>[src]
Returns this format's representation of separators.
pub fn set_infinity<S>(&mut self, value: S) -> Result<(), Error> where
S: AsRef<str>, [src]
S: AsRef<str>,
pub fn set_nan<S>(&mut self, value: S) -> Result<(), Error> where
S: AsRef<str>, [src]
S: AsRef<str>,
Trait Implementations
impl Format for Environment[src]
fn decimal(&self) -> char[src]
fn grouping(&self) -> Grouping[src]
fn infinity(&self) -> InfinityStr[src]
fn minus_sign(&self) -> MinusSignStr[src]
fn nan(&self) -> NanStr[src]
fn separator(&self) -> Option<char>[src]
impl Eq for Environment[src]
impl Clone for Environment[src]
fn clone(&self) -> Environment[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Copy for Environment[src]
impl PartialEq<Environment> for Environment[src]
fn eq(&self, other: &Environment) -> bool[src]
fn ne(&self, other: &Environment) -> bool[src]
impl Hash for Environment[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more
impl Debug for Environment[src]
Auto Trait Implementations
impl Send for Environment
impl Sync for Environment
Blanket Implementations
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> From for T[src]
impl<T, U> TryFrom for T where
U: Into<T>, [src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
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, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
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.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,