toasty_core/stmt/
value_cmp.rs1use super::{Expr, Value};
7
8macro_rules! impl_value_eq {
10 ($($ty:ty => $variant:ident),* $(,)?) => {
11 $(
12 impl PartialEq<$ty> for Value {
14 fn eq(&self, other: &$ty) -> bool {
15 matches!(self, Value::$variant(val) if val == other)
16 }
17 }
18
19 impl PartialEq<$ty> for Expr {
21 fn eq(&self, other: &$ty) -> bool {
22 matches!(self, Expr::Value(Value::$variant(val)) if val == other)
23 }
24 }
25
26 impl PartialEq<Value> for $ty {
28 fn eq(&self, other: &Value) -> bool {
29 other.eq(self)
30 }
31 }
32 )*
33 };
34}
35
36impl_value_eq! {
38 bool => Bool,
39}
40
41impl PartialEq<String> for Value {
45 fn eq(&self, other: &String) -> bool {
46 matches!(self, Value::String(val) if val == other)
47 }
48}
49
50impl PartialEq<String> for Expr {
52 fn eq(&self, other: &String) -> bool {
53 matches!(self, Expr::Value(Value::String(val)) if val == other)
54 }
55}
56
57impl PartialEq<&str> for Value {
59 fn eq(&self, other: &&str) -> bool {
60 matches!(self, Value::String(val) if val == other)
61 }
62}
63
64impl PartialEq<&str> for Expr {
66 fn eq(&self, other: &&str) -> bool {
67 matches!(self, Expr::Value(Value::String(val)) if val == other)
68 }
69}
70
71impl PartialEq<str> for Value {
73 fn eq(&self, other: &str) -> bool {
74 matches!(self, Value::String(val) if val == other)
75 }
76}
77
78impl PartialEq<str> for Expr {
80 fn eq(&self, other: &str) -> bool {
81 matches!(self, Expr::Value(Value::String(val)) if val == other)
82 }
83}
84
85impl PartialEq<Value> for String {
89 fn eq(&self, other: &Value) -> bool {
90 other.eq(self)
91 }
92}
93
94impl PartialEq<Value> for &str {
96 fn eq(&self, other: &Value) -> bool {
97 other.eq(self)
98 }
99}
100
101impl PartialEq<Value> for str {
103 fn eq(&self, other: &Value) -> bool {
104 other.eq(self)
105 }
106}