Trait num_format::parsing::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).

Object Safety§

This trait is not object safe.

Implementors§

source§

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