#regex-parser #proc-macro #data

regex_with

A Rust library providing procedural macros for regex-based parsing and validation of custom data types

2 releases

0.1.1 Jul 13, 2024
0.1.0 Jul 13, 2024

#19 in #regex-parser

Download history 179/week @ 2024-07-11 12/week @ 2024-07-18 16/week @ 2024-07-25 20/week @ 2024-09-12 11/week @ 2024-09-19 13/week @ 2024-09-26 7/week @ 2024-10-03

51 downloads per month

MIT license

6KB
109 lines

The regex_with library provides Rust procedural macros to enable regex-based parsing capabilities for custom types. It simplifies the integration of regex patterns into the parsing process of data structures.

Example

use regex_with::{Capturable, de::FromStr};
#[derive(serde::Deserialize, Capturable, FromStr)]
#[regex_with(re = "^(?P<id>\\d+)$")]
struct Record {
    id: u32,
}

let record: Record = "123".parse().unwrap();
assert_eq!(record.id, 123);

Dependencies

~2.5–4MB
~76K SLoC