~jojo/microcrisp

ddf1700d5ba2363276ada1669670e188e7d38419 — JoJo 1 year, 4 months ago aaaa676
impl From for Lisp for i64, &str, Option
1 files changed, 22 insertions(+), 0 deletions(-)

M src/lib.rs
M src/lib.rs => src/lib.rs +22 -0
@@ 236,6 236,28 @@ impl Lisp {
    }
}

impl From<i64> for Lisp {
    fn from(x: i64) -> Lisp {
        Lisp::Int(x)
    }
}
impl From<&str> for Lisp {
    fn from(s: &str) -> Lisp {
        Lisp::String(s.to_owned())
    }
}
impl<T> From<Option<T>> for Lisp
where
    Lisp: From<T>,
{
    fn from(x: Option<T>) -> Lisp {
        match x {
            Some(x) => Lisp::List(vec![Lisp::Symbol(Symbol::pack_str("some").unwrap()), Lisp::from(x)]),
            None => Lisp::Symbol(Symbol::pack_str("none").unwrap()),
        }
    }
}

impl PartialEq<i64> for Lisp {
    fn eq(&self, rhs: &i64) -> bool {
        match self {