From 83ab1a930fec4ed6e2c419f66e2187552345f6b6 Mon Sep 17 00:00:00 2001 From: m Date: Sun, 4 Aug 2024 18:03:03 -0700 Subject: [PATCH] add Value::Bool --- src/interpreter/value.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/interpreter/value.rs b/src/interpreter/value.rs index 5d3efa5..0c4ef7b 100644 --- a/src/interpreter/value.rs +++ b/src/interpreter/value.rs @@ -22,6 +22,7 @@ pub enum Value { Null, Float(f64), Int(i64), + Bool(bool), String(Arc), List(Vec>), Structure(Structure), @@ -68,6 +69,7 @@ impl Value { Null => Null, Float(f) => Float(f), Int(i) => Int(i), + Bool(b) => Bool(b), String(s) => String(s), List(l) => List(l.into_iter().map(Self::from_data).collect()), Structure(s) => Structure( @@ -86,6 +88,7 @@ impl Value { Null => Some(Null), Float(f) => Some(Float(f)), Int(i) => Some(Int(i)), + Bool(b) => Some(Bool(b)), String(s) => Some(String(s)), List(l) => Some(List(l.into_iter().filter_map(Self::into_data).collect())), Structure(s) => Some(Structure( @@ -163,6 +166,7 @@ impl<'a> From> for EValue<'a> { Null => Null, Float(f) => Float(f), Int(i) => Int(i), + Bool(b) => Bool(b), String(s) => String(s), List(l) => List(l.into_iter().map(Self::from).collect()), Structure(s) => Structure(s.into_iter().map(|(k, v)| (k, v.into())).collect()), @@ -178,6 +182,7 @@ impl<'a> From> for PValue<'a> { Null => Null, Float(f) => Float(f), Int(i) => Int(i), + Bool(b) => Bool(b), String(s) => String(s), List(l) => List(l.into_iter().map(Self::from).collect()), Structure(s) => Structure(s.into_iter().map(|(k, v)| (k, v.into())).collect()), @@ -197,6 +202,7 @@ impl fmt::Display for Value { Self::Null => write!(f, "null"), Self::Int(n) => write!(f, "{n}"), Self::Float(x) => write!(f, "{x}"), + Self::Bool(b) => write!(f, "{b}"), Self::String(s) => write!(f, r#""{s}""#), Self::List(ls) => { write!(f, "[")?;