str-newtype 2.0.0

Derive macro to define safe wrappers around string types
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use static_automata::{Validate, grammar};
use str_newtype::StrNewType;

#[grammar(file = "iri.abnf", export("IRI"))]
mod automata {}

/// IRI.
#[derive(Validate, StrNewType, PartialEq, Eq, PartialOrd, Ord)]
#[automaton(automata::Iri)]
#[newtype(
    ord(str, &str, String),
    owned(IriBuf, derive(PartialEq))
)]
pub struct Iri(str);

fn main() {
	Iri::new("https://www.rust-lang.org/foo/bar?query#frag").unwrap();
}