[−][src]Derive Macro onehot_derive::OneHot
#[derive(OneHot)] { // Attributes available to this derive: #[onehot] }
The auto derive macro for OneHot.
Enums and structs:
ⓘThis example is not tested
#[derive(OneHot)] pub enum SimpleEnum { First, Second, #[onehot(ignore)] // Fields with the `ignore` attribute are disconsidered. Third, } #[derive(OneHot)] struct SimpleStruct { f1: bool, f2: SimpleEnum, }
Structs can also be tuple and/or generic:
ⓘThis example is not tested
#[derive(OneHot)] pub struct SimpleGenericStruct<'a, T: OneHot + 'a>( bool, &'a T, #[onehot(ignore)] u32 );