diff --git a/Cargo.lock b/Cargo.lock index 0245981..d994b8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,7 +88,7 @@ dependencies = [ [[package]] name = "crisp" -version = "0.1.3" +version = "0.1.0" dependencies = [ "lazy_static", "miette", diff --git a/Cargo.toml b/Cargo.toml index 0c47f3e..5b002e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "crisp" -version = "0.1.3" +version = "0.1.0" edition = "2021" [lib] -name = "crisp" +crate-type = ["staticlib"] path = "src/lib.rs" [dependencies] diff --git a/src/lib.rs b/src/lib.rs index ba57106..0a8870f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ pub mod reader; pub mod types; use types::*; -fn main() -> Result<()> { +pub fn main() -> Result<()> { let mut rl = Editor::<(), rustyline::history::DefaultHistory>::new().unwrap(); if rl.load_history(".mal-history").is_err() { eprintln!("No previous history."); diff --git a/src/types.rs b/src/types.rs index 96e0700..b553a70 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,4 +1,4 @@ -use miette::{miette, Result}; +use color_eyre::{eyre::eyre, Result}; use std::{num::ParseIntError, rc::Rc}; #[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)] @@ -46,14 +46,7 @@ impl Value { pub fn apply(&self, args: LispArgs) -> Result { match self { Self::Function(f, _) => f(args), - _ => Err(miette!("No function here, shouldn't call apply")), - } - } - - pub fn is_list(&self) -> bool { - match self { - Self::List(_) => true, - _ => false, + _ => Err(eyre!("No function here, shouldn't call apply")), } } } @@ -107,64 +100,6 @@ impl From<&i64> for Value { } } -impl From 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(), - } - } -} - -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(), - } - } -} - -impl From for i32 { - fn from(value: Value) -> Self { - match value { - Value::Number(num) => num as i32, - _ => 0, - } - } -} - -impl From for i64 { - fn from(value: Value) -> Self { - match value { - Value::Number(num) => num, - _ => 0, - } - } -} - -impl From<&Value> for i32 { - fn from(value: &Value) -> Self { - match value { - Value::Number(num) => *num as i32, - _ => 0, - } - } -} - -impl From<&Value> for i64 { - fn from(value: &Value) -> Self { - match value { - Value::Number(num) => *num, - _ => 0, - } - } -} - #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct Symbol(pub String); @@ -194,16 +129,3 @@ impl std::fmt::Display for Keyword { std::fmt::Display::fmt(&self.0, f) } } - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_conversions() { - let value = Value::Symbol(Symbol("c1".to_owned())); - let string = String::from("c1"); - let convert = String::from(value); - assert_eq!(string, convert); - } -}