re-parse-macros

Crates.iore-parse-macros
lib.rsre-parse-macros
version0.1.0
sourcesrc
created_at2018-12-04 22:44:17.156719
updated_at2018-12-04 22:44:17.156719
descriptionMacros for re-parse
homepage
repositoryhttps://github.com/kardeiz/re-parse
max_upload_size
id100121
size3,453
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