re-parse

Crates.iore-parse
lib.rsre-parse
version0.1.0
sourcesrc
created_at2018-12-04 22:45:52.512611
updated_at2018-12-04 22:45:52.512611
descriptionParse into a struct using Regex
homepage
repositoryhttps://github.com/kardeiz/re-parse
max_upload_size
id100122
size3,735
Jacob Brown (kardeiz)

documentation

README

re-parse

Implements FromStr for a struct using Regex and serde_urlencoded.

Usage

#[derive(Debug, Eq, PartialEq, PartialOrd, Ord, Deserialize, ReParse)]
#[re_parse(regex=r#"(?x)
    \[
        (?P<year>[0-9]{4})-(?P<month>[0-9]{2})-(?P<day>[0-9]{2})
        \s+
        (?P<hour>[0-9]{2}):(?P<minute>[0-9]{2})
    \]
"#)]
struct DateTime {
    year: u32,
    month: u32,
    day: u32,
    hour: u32,
    minute: u32,
}

fn main() {

    let x: DateTime = "[1518-11-01 00:00]".parse().unwrap();

    println!("{:?}", &x);
}
Commit count: 5

cargo fmt