adding conversions for symbols and keywords to strings
This commit is contained in:
parent
c3abe2fe48
commit
2489bf56dc
1 changed files with 11 additions and 0 deletions
11
src/types.rs
11
src/types.rs
|
@ -49,6 +49,13 @@ impl Value {
|
|||
_ => 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 {
|
||||
|
@ -104,6 +111,8 @@ impl From<Value> for String {
|
|||
fn from(value: Value) -> Self {
|
||||
match value {
|
||||
Value::String(str) => str,
|
||||
Value::Symbol(Symbol(str)) => str,
|
||||
Value::Keyword(Keyword(str)) => str,
|
||||
_ => String::default(),
|
||||
}
|
||||
}
|
||||
|
@ -113,6 +122,8 @@ impl From<&Value> for String {
|
|||
fn from(value: &Value) -> Self {
|
||||
match value {
|
||||
Value::String(str) => str.clone(),
|
||||
Value::Symbol(Symbol(str)) => str.clone(),
|
||||
Value::Keyword(Keyword(str)) => str.clone(),
|
||||
_ => String::default(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue