| Crates.io | re-parse |
| lib.rs | re-parse |
| version | 0.1.0 |
| created_at | 2018-12-04 22:45:52.512611+00 |
| updated_at | 2018-12-04 22:45:52.512611+00 |
| description | Parse into a struct using Regex |
| homepage | |
| repository | https://github.com/kardeiz/re-parse |
| max_upload_size | |
| id | 100122 |
| size | 3,735 |
Implements FromStr for a struct using Regex and serde_urlencoded.
#[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);
}