| 1 | #![macro_use ] |
| 2 | |
| 3 | //! Contains several macros used in this crate. |
| 4 | |
| 5 | macro_rules! gen_setter { |
| 6 | ($(#[$comments:meta])* $field:ident : into $t:ty) => { |
| 7 | |
| 8 | $(#[$comments])* |
| 9 | /// |
| 10 | /// <small>See [`ParserConfig`][crate::ParserConfig] fields docs for details</small> |
| 11 | #[inline] |
| 12 | #[must_use] |
| 13 | pub fn $field<T: Into<$t>>(mut self, value: T) -> Self { |
| 14 | self.$field = value.into(); |
| 15 | self |
| 16 | } |
| 17 | }; |
| 18 | ($(#[$comments:meta])* $field:ident : val $t:ty) => { |
| 19 | $(#[$comments])* |
| 20 | /// |
| 21 | /// <small>See [`ParserConfig`][crate::ParserConfig] fields docs for details</small> |
| 22 | #[inline] |
| 23 | #[must_use] |
| 24 | pub const fn $field(mut self, value: $t) -> Self { |
| 25 | self.$field = value; |
| 26 | self |
| 27 | } |
| 28 | }; |
| 29 | ($(#[$comments:meta])* $field:ident : delegate $t:ty) => { |
| 30 | $(#[$comments])* |
| 31 | /// |
| 32 | /// <small>See [`ParserConfig`][crate::ParserConfig] fields docs for details</small> |
| 33 | #[inline] |
| 34 | #[must_use] |
| 35 | pub const fn $field(mut self, value: $t) -> Self { |
| 36 | self.c.$field = value; |
| 37 | self |
| 38 | } |
| 39 | }; |
| 40 | ($(#[$comments:meta])* $field:ident : c2 $t:ty) => { |
| 41 | $(#[$comments])* |
| 42 | /// |
| 43 | /// <small>See [`ParserConfig2`][crate::reader::ParserConfig2] fields docs for details</small> |
| 44 | #[inline] |
| 45 | #[must_use] |
| 46 | pub fn $field(self, value: $t) -> ParserConfig2 { |
| 47 | ParserConfig2 { |
| 48 | c: self, |
| 49 | ..Default::default() |
| 50 | } |
| 51 | .$field(value) |
| 52 | } |
| 53 | }; |
| 54 | } |
| 55 | |
| 56 | macro_rules! gen_setters { |
| 57 | ($target:ident, $($(#[$comments:meta])* $field:ident : $k:tt $tpe:ty),+) => ( |
| 58 | impl $target {$( |
| 59 | |
| 60 | gen_setter! { $(#[$comments])* $field : $k $tpe } |
| 61 | )+ |
| 62 | }) |
| 63 | } |
| 64 | |