From 3eb53c36123c4a8a8f336c255a9d5a7b44ca922c Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Sun, 28 Jun 2020 19:50:11 -0500 Subject: Implement Display for Type and SExpr. --- src/lib/sexpr.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/lib/sexpr.rs') 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) } +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))); -- cgit v1.2.3