Function time::parse[][src]

pub fn parse<T: Parsable>(
    s: impl AsRef<str>,
    format: impl AsRef<str>
) -> Result<T, Error>

Parse any parsable type from the time crate.

This is identical to calling T::parse(s, format), but allows the use of type inference where possible.

use time::Time;

#[derive(Debug)]
struct Foo(Time);

fn main() -> time::Result<()> {
    // We don't need to tell the compiler what type we need!
    let foo = Foo(time::parse("14:55:02", "%T")?);
    println!("{:?}", foo);
    Ok(())
}