pub trait ParseFormatted {
    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

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

Implementors