wp_model_core/model/
macros.rs

1#[macro_export]
2macro_rules! value_match {
3    ($obj:expr,$what :expr) => {
4        match $obj {
5            $crate::model::Value::Bool(x) => $what(x),
6            $crate::model::Value::Chars(x) => $what(x),
7            $crate::model::Value::Symbol(x) => $what(x.to_string()),
8            $crate::model::Value::Digit(x) => $what(x),
9            $crate::model::Value::Time(x) => $what(x),
10            $crate::model::Value::Hex(x) => $what(x),
11            $crate::model::Value::Float(x) => $what(x),
12            $crate::model::Value::IpNet(x) => $what(x),
13            $crate::model::Value::IpAddr(x) => $what(x),
14            $crate::model::Value::Ignore(x) => $what(x),
15            $crate::model::Value::Obj(x) => $what(x),
16            $crate::model::Value::Array(x) => $what(x),
17            $crate::model::Value::Domain(x) => $what(x),
18            $crate::model::Value::Url(x) => $what(x),
19            $crate::model::Value::Email(x) => $what(x),
20            $crate::model::Value::IdCard(x) => $what(x),
21            $crate::model::Value::MobilePhone(x) => $what(x),
22        }
23    };
24    ($obj:expr,$what :expr,$a1:expr) => {
25        match $obj {
26            $crate::model::Value::Bool(x) => $what(x, $a1),
27            $crate::model::Value::Chars(x) => $what(x, $a1),
28            $crate::model::Value::Symbol(x) => $what(x.to_string(), $a1),
29            $crate::model::Value::Digit(x) => $what(x, $a1),
30            $crate::model::Value::Time(x) => $what(x, $a1),
31            $crate::model::Value::Hex(x) => $what(x, $a1),
32            $crate::model::Value::Float(x) => $what(x, $a1),
33            $crate::model::Value::IpNet(x) => $what(x, $a1),
34            $crate::model::Value::IpAddr(x) => $what(x, $a1),
35            $crate::model::Value::Ignore(x) => $what(x, $a1),
36            $crate::model::Value::Obj(x) => $what(x, $a1),
37            $crate::model::Value::Array(x) => $what(x, $a1),
38            $crate::model::Value::Domain(x) => $what(x, $a1),
39            $crate::model::Value::Url(x) => $what(x, $a1),
40            $crate::model::Value::Email(x) => $what(x, $a1),
41            $crate::model::Value::IdCard(x) => $what(x, $a1),
42            $crate::model::Value::MobilePhone(x) => $what(x, $a1),
43        }
44    };
45    ($obj:expr,$what :expr,$a1:expr,$a2:expr) => {
46        match $obj {
47            $crate::model::Value::Bool(x) => $what(x, $a1, $a2),
48            $crate::model::Value::Chars(x) => $what(x, $a1, $a2),
49            $crate::model::Value::Symbol(x) => $what(x.to_string(), $a1, $a2),
50            $crate::model::Value::Digit(x) => $what(x, $a1, $a2),
51            $crate::model::Value::Time(x) => $what(x, $a1, $a2),
52            $crate::model::Value::Hex(x) => $what(x, $a1, $a2),
53            $crate::model::Value::Float(x) => $what(x, $a1, $a2),
54            $crate::model::Value::IpNet(x) => $what(x, $a1, $a2),
55            $crate::model::Value::IpAddr(x) => $what(x, $a1, $a2),
56            $crate::model::Value::Ignore(x) => $what(x, $a1, $a2),
57            $crate::model::Value::Obj(x) => $what(x, $a1, $a2),
58            $crate::model::Value::Array(x) => $what(x, $a1, $a2),
59            $crate::model::Value::Domain(x) => $what(x, $a1, $a2),
60            $crate::model::Value::Url(x) => $what(x, $a1, $a2),
61            $crate::model::Value::Email(x) => $what(x, $a1, $a2),
62            $crate::model::Value::IdCard(x) => $what(x, $a1, $a2),
63            $crate::model::Value::MobilePhone(x) => $what(x, $a1, $a2),
64        }
65    };
66}
67
68#[macro_export]
69macro_rules! format_value {
70    ($obj:expr,$what : ident ,$a1:expr) => {
71        match $obj {
72            $crate::model::Value::Bool(x) => $what(x).fmt($a1),
73            $crate::model::Value::Chars(x) => $what(x).fmt($a1),
74            $crate::model::Value::Symbol(x) => $what(x.to_string()).fmt($a1),
75            $crate::model::Value::Digit(x) => $what(x).fmt($a1),
76            $crate::model::Value::Time(x) => $what(x).fmt($a1),
77            $crate::model::Value::Hex(x) => $what(x).fmt($a1),
78            $crate::model::Value::Float(x) => $what(x).fmt($a1),
79            $crate::model::Value::IpNet(x) => $what(x).fmt($a1),
80            $crate::model::Value::IpAddr(x) => $what(x).fmt($a1),
81            $crate::model::Value::Ignore(x) => $what(x).fmt($a1),
82            $crate::model::Value::Obj(x) => $what(x).fmt($a1),
83            $crate::model::Value::Array(x) => $what(x).fmt($a1),
84            $crate::model::Value::Domain(x) => $what(x).fmt($a1),
85            $crate::model::Value::Url(x) => $what(x).fmt($a1),
86            $crate::model::Value::Email(x) => $what(x).fmt($a1),
87            $crate::model::Value::IdCard(x) => $what(x).fmt($a1),
88            $crate::model::Value::MobilePhone(x) => $what(x).fmt($a1),
89        }
90    };
91}