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