1use super::*;
2
3#[derive(PartialEq, Debug, Clone)]
4pub struct Condition<'src> {
5 pub lhs: Box<Expression<'src>>,
6 pub rhs: Box<Expression<'src>>,
7 pub operator: ConditionalOperator,
8}
9
10impl<'src> Display for Condition<'src> {
11 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
12 write!(f, "{} {} {}", self.lhs, self.operator, self.rhs)
13 }
14}
15
16impl<'src> Serialize for Condition<'src> {
17 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
18 where
19 S: Serializer,
20 {
21 let mut seq = serializer.serialize_seq(None)?;
22 seq.serialize_element(&self.operator.to_string())?;
23 seq.serialize_element(&self.lhs)?;
24 seq.serialize_element(&self.rhs)?;
25 seq.end()
26 }
27}