use super::*;
pub fn when(condition: Expr) -> WhenBuilder {
WhenBuilder(condition)
}
pub struct WhenBuilder(Expr);
impl WhenBuilder {
pub fn then(self, value: impl IntoExpr) -> ThenBuilder {
ThenBuilder { condition: self.0, true_val: value.into_expr() }
}
}
pub struct ThenBuilder {
condition: Expr,
true_val: Expr,
}
impl ThenBuilder {
pub fn otherwise(self, value: impl IntoExpr) -> Expr {
Expr::IfElse {
condition: Box::new(self.condition),
true_val: Box::new(self.true_val),
false_val: Box::new(value.into_expr()),
}
}
}