Trait ParseFormatted

Source
pub trait ParseFormatted {
    // Required method
    fn parse_formatted<F, N>(&self, format: &F) -> Result<N, Error>
       where F: Format,
             N: FromFormattedStr;
}
Expand description

Trait that provides string-like types with a parse_formatted method, allowing conversion from a formatted string into a number.

§Examples

use num_format::Locale;
use num_format::parsing::ParseFormatted;

fn main() {
    let s = "1,000,000";
    let n = s.parse_formatted::<_, u32>(&Locale::en).unwrap();
    assert_eq!(n, 1_000_000);
}

Required Methods§

Source

fn parse_formatted<F, N>(&self, format: &F) -> Result<N, Error>
where F: Format, N: FromFormattedStr,

Converts self (typically a formatted string) into a number (see Examples above).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S> ParseFormatted for S
where S: AsRef<str>,