macro_rules! constr {
(
$(
$(#[$attr:meta])*
$vis:vis type $name:ident = $(($($flag:ident),* $(,)?))? $lit:literal;
)*
) => { ... };
}Expand description
Creates an impl Constr type for a string.
Allows implementing marker traits as well: in order to avoid using a proc macro, these have to be explicitly specified. Validity is ensured at compile time to avoid accidental unsoundness.
This macro will only accept nonempty strings. For the empty string, use Empty instead.
§Examples
use constr::constr
constr! {
/// Caseless string with non-ASCII characters.
pub type Caseless = (Caseless) "中 ?";
/// Caseless ASCII string.
pub(crate) type All = (Ascii, Caseless) "???";
/// Cased string.
type Cased = "AAAあ";
}