Skip to content

Commit

Permalink
add Value::Bool
Browse files Browse the repository at this point in the history
  • Loading branch information
suaviloquence committed Aug 5, 2024
1 parent 3397951 commit 83ab1a9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/interpreter/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub enum Value<T = Data> {
Null,
Float(f64),
Int(i64),
Bool(bool),
String(Arc<str>),
List(Vec<Value<T>>),
Structure(Structure<T>),
Expand Down Expand Up @@ -68,6 +69,7 @@ impl<X> Value<X> {
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(
Expand All @@ -86,6 +88,7 @@ impl<X> Value<X> {
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(
Expand Down Expand Up @@ -163,6 +166,7 @@ impl<'a> From<PValue<'a>> 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()),
Expand All @@ -178,6 +182,7 @@ impl<'a> From<EValue<'a>> 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()),
Expand All @@ -197,6 +202,7 @@ impl<T: fmt::Display> fmt::Display for Value<T> {
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, "[")?;
Expand Down

0 comments on commit 83ab1a9

Please sign in to comment.