diff options
Diffstat (limited to 'src/lib/sexpr.rs')
-rw-r--r-- | src/lib/sexpr.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/sexpr.rs b/src/lib/sexpr.rs index a6fbe49..6956b9b 100644 --- a/src/lib/sexpr.rs +++ b/src/lib/sexpr.rs @@ -1,3 +1,5 @@ +use std::fmt; + use super::types::Type; #[derive(PartialEq, Debug)] @@ -6,6 +8,15 @@ pub enum SExpr { Sexpr(Vec<SExpr>) } +impl fmt::Display for SExpr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + SExpr::Atom(ref t) => write!(f, "{}", t), + SExpr::Sexpr(ref s) => write!(f, "{:?}", s) + } + } +} + #[test] fn construct() { let atom1 = SExpr::Atom(Type::Number(Number::Int(1))); |