1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
pub macro builder_functions( $( $attr:ident($t:ty) $(,)? )* ) { $( pub fn $attr(mut self, value: impl Into<$t>) -> Self { self.$attr = Some(value.into()); self } )* } pub macro builder_enum_functions( $( $attr:ident { $( $fn:ident() => $value:expr $(,)? )* } $(,)? )* ) { $( $( pub fn $fn(mut self) -> Self { self.$attr = Some($value.into()); self } )* )* } pub macro value_functions( $( $attr:ident { $( $fn:ident() => $value:expr $(,)? )* } $(,)? )* ) { $( $( pub fn $fn(mut self) -> Self { self.$attr = $value.into(); self } )* )* } pub macro composition_functions( $( $attr:ident: $ty:ty $(,)? )* ) { $( pub fn $attr(mut self, get_new_value: impl FnOnce($ty) -> $ty) -> Self { self.$attr = get_new_value(self.$attr); self } )* } pub macro option_composition_functions( $( $attr:ident: $ty:ident $(,)? )* ) { $( pub fn $attr(mut self, get_new_value: impl FnOnce($ty) -> $ty) -> Self { self.$attr = Some(get_new_value(self.$attr.unwrap_or_default())); self } )* } pub macro bool_functions ( $( $fn:ident() => $attr:ident $(,)? )* ) { $( pub fn $fn(&self) -> bool { self.$attr } )* } pub macro view_data_functions ( $( $fn:ident() => $attr:ident $(,)? )* ) { $( pub fn as_$fn(&self) -> &$ty { &self.$attr } )* }