Crates.io | re-parse-macros |
lib.rs | re-parse-macros |
version | 0.1.0 |
source | src |
created_at | 2018-12-04 22:44:17.156719 |
updated_at | 2018-12-04 22:44:17.156719 |
description | Macros for re-parse |
homepage | |
repository | https://github.com/kardeiz/re-parse |
max_upload_size | |
id | 100121 |
size | 3,453 |
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);
}