adding conversions for symbols and keywords to strings

This commit is contained in:
Chris Cochrun 2024-11-29 21:59:33 -06:00
parent c3abe2fe48
commit 2489bf56dc

View file

@ -49,6 +49,13 @@ impl Value {
_ => Err(miette!("No function here, shouldn't call apply")), _ => Err(miette!("No function here, shouldn't call apply")),
} }
} }
pub fn is_list(&self) -> bool {
match self {
Self::List(_) => true,
_ => false,
}
}
} }
impl From<Vec<Value>> for Value { impl From<Vec<Value>> for Value {
@ -104,6 +111,8 @@ impl From<Value> for String {
fn from(value: Value) -> Self { fn from(value: Value) -> Self {
match value { match value {
Value::String(str) => str, Value::String(str) => str,
Value::Symbol(Symbol(str)) => str,
Value::Keyword(Keyword(str)) => str,
_ => String::default(), _ => String::default(),
} }
} }
@ -113,6 +122,8 @@ impl From<&Value> for String {
fn from(value: &Value) -> Self { fn from(value: &Value) -> Self {
match value { match value {
Value::String(str) => str.clone(), Value::String(str) => str.clone(),
Value::Symbol(Symbol(str)) => str.clone(),
Value::Keyword(Keyword(str)) => str.clone(),
_ => String::default(), _ => String::default(),
} }
} }