Refactor Value::is_true()

This commit is contained in:
ConnorSkees 2020-02-08 16:01:21 -05:00
parent 29917d95d4
commit 789c55ac3d

View File

@ -226,8 +226,11 @@ impl Value {
}
pub fn is_true(&self) -> bool {
let s = self.eval();
!(s == Value::Null || s == Value::False)
match self {
Value::Null | Value::False => false,
Self::BinaryOp(..) => self.eval().is_true(),
_ => true
}
}
pub fn unquote(self) -> Self {