toasty_core/stmt/
value_cmp.rs1use super::{Expr, Value};
21
22macro_rules! impl_value_eq {
24 ($($ty:ty => $variant:ident),* $(,)?) => {
25 $(
26 impl PartialEq<$ty> for Value {
28 fn eq(&self, other: &$ty) -> bool {
29 matches!(self, Value::$variant(val) if val == other)
30 }
31 }
32
33 impl PartialEq<$ty> for Expr {
35 fn eq(&self, other: &$ty) -> bool {
36 matches!(self, Expr::Value(Value::$variant(val)) if val == other)
37 }
38 }
39
40 impl PartialEq<Value> for $ty {
42 fn eq(&self, other: &Value) -> bool {
43 other.eq(self)
44 }
45 }
46 )*
47 };
48}
49
50impl_value_eq! {
52 bool => Bool,
53}
54
55impl PartialEq<String> for Value {
59 fn eq(&self, other: &String) -> bool {
60 matches!(self, Value::String(val) if val == other)
61 }
62}
63
64impl PartialEq<String> for Expr {
66 fn eq(&self, other: &String) -> 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<str> for Value {
87 fn eq(&self, other: &str) -> bool {
88 matches!(self, Value::String(val) if val == other)
89 }
90}
91
92impl PartialEq<str> for Expr {
94 fn eq(&self, other: &str) -> bool {
95 matches!(self, Expr::Value(Value::String(val)) if val == other)
96 }
97}
98
99impl PartialEq<Value> for String {
103 fn eq(&self, other: &Value) -> bool {
104 other.eq(self)
105 }
106}
107
108impl PartialEq<Value> for &str {
110 fn eq(&self, other: &Value) -> bool {
111 other.eq(self)
112 }
113}
114
115impl PartialEq<Value> for str {
117 fn eq(&self, other: &Value) -> bool {
118 other.eq(self)
119 }
120}