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
pub use crate::{
client::{auth::*, options::*},
coll::options::*,
collation::*,
concern::*,
db::options::*,
selection_criteria::*,
};
macro_rules! resolve_options {
($obj:expr, $opts:expr, [$( $field:ident ),+] ) => {
$(
if let Some(option) = $obj.$field() {
if !$opts
.as_ref()
.map(|opts| opts.$field.is_some())
.unwrap_or(false)
{
$opts.get_or_insert_with(Default::default).$field = Some(option.clone());
}
}
)+
};
}
#[cfg(test)]
macro_rules! merge_options {
($src:expr, $dst:expr, [$( $field:ident ),+] ) => {
$(
if let Some(option) = $src.$field {
if !$dst.$field.is_some() {
$dst.$field = Some(option.clone());
}
}
)+
};
}