[−][src]Struct num_format::Environment
Type for obtaining your system locale from the LC_ALL
environment variable. Implements Format
.
Example
use std::env; use num_format::{Environment, Error, ToFormattedString}; fn main() -> Result<(), 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
setlocale
andlocaleconv
API from C in order to access your system's locale settings specified by theLC_ALL
environment 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_infinity
andset_nan
methods.
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 From<Environment> for CustomFormat
[src]
fn from(environment: Environment) -> Self
[src]
impl PartialEq<Environment> for Environment
[src]
fn eq(&self, other: &Environment) -> bool
[src]
fn ne(&self, other: &Environment) -> bool
[src]
impl Eq for Environment
[src]
impl Copy 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 Debug for Environment
[src]
impl Hash 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> From for T
[src]
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 = !
🔬 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> 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>,