[−][src]Macro lhlist::new_label
Macro for easily creating a label struct.
There are three formats for calling this macro:
use lhlist::Label; // default name (variable name), nil associated type `()` new_label![MyLabel1]; assert_eq!(MyLabel1::name(), "MyLabel1"); // default name (variable name) with associated type new_label![MyLabel2: u8]; assert_eq!(MyLabel2::name(), "MyLabel2"); assert_eq!(<MyLabel2 as Label>::AssocType::max_value(), u8::max_value()); new_label![MyLabel3("My Custom Label"): u16]; assert_eq!(MyLabel3::name(), "My Custom Label"); assert_eq!(<MyLabel3 as Label>::AssocType::max_value(), u16::max_value());
Alternatively (and equivalently), you can use the #[label(type=T, name="Name")]
attribute format:
use lhlist::Label; #[label] struct MyLabel1; assert_eq!(MyLabel1::name(), "MyLabel1"); #[label(type=Vec<u32>)] struct MyLabel2; assert_eq!(MyLabel2::name(), "MyLabel2"); #[label(name="My Custom Label", type=Vec<u32>)] struct MyLabel3; assert_eq!(MyLabel3::name(), "My Custom Label");