Crate regex_with

source ·
Expand description

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);

Re-exports§

Modules§

Derive Macros§

  • Helper macro for deriving the FromStr trait for a struct that captures regular expressions. regex_with that specifies the regular expression pattern.