Macro char_property
macro_rules! char_property {
(
$(#[$prop_meta:meta])*
pub enum $prop_name:ident {
abbr => $prop_abbr:expr;
long => $prop_long:expr;
human => $prop_human:expr;
$(
$(#[$variant_meta:meta])*
$variant_name:ident {
abbr => $variant_abbr:ident,
long => $variant_long:ident,
human => $variant_human:expr,
}
)*
}
$(#[$abbr_mod_meta:meta])*
pub mod $abbr_mod:ident for abbr;
$(#[$long_mod_meta:meta])*
pub mod $long_mod:ident for long;
) => { ... };
(
$(#[$prop_meta:meta])*
pub struct $prop_name:ident(bool) {
abbr => $prop_abbr:expr;
long => $prop_long:expr;
human => $prop_human:expr;
data_table_path => $data_path:expr;
}
$(#[$is_fn_meta:meta])*
pub fn $is_fn:ident(char) -> bool;
) => { ... };
(
__impl CharProperty for $prop_name:ident;
$prop_abbr:expr;
$prop_long:expr;
$prop_human:expr;
) => { ... };
(
__impl FromStr for $prop_name:ident;
$( $id:expr => $value:expr; )*
) => { ... };
( __impl Display for $prop_name:ident by $trait:ident ) => { ... };
}
Macro for declaring a character property.
Syntax (Enumerated Property)
extern crate unic_char_property;
// First we define the type itself.
char_property!
// We also need to impl `PartialCharProperty` or `TotalCharProperty` manually.
#
#
#
Syntax (Binary Property)
extern crate unic_char_property;
# extern crate unic_char_range;
char_property!
// You may also want to create a trait for easy access to the properties you define.
#
Effect
- Implements the
CharPropertytrait and appropriate range trait - Implements
FromStraccepting either the abbr or long name, ascii case insensitive - Implements
Displayusing thehumanstring - Populates the module
abbr_nameswithpub usebindings of variants to their abbr names (Enumerated properties only) - Populates the module
long_nameswithpub usebindings of variants to their long names (Enumerated properties only) - Maintains all documentation comments and other
#[attributes]as would be expected (with some limitations, listed below)