summaryrefslogtreecommitdiff
path: root/src/lib/sexpr.rs
diff options
context:
space:
mode:
authorDominick Allen <dominick.allen1989@gmail.com>2020-06-28 19:50:11 -0500
committerDominick Allen <dominick.allen1989@gmail.com>2020-06-28 19:50:11 -0500
commit3eb53c36123c4a8a8f336c255a9d5a7b44ca922c (patch)
tree15eaa77059a357f11170ba3e19da278f855eaa9e /src/lib/sexpr.rs
parent5857746f39f1fe36a83c6145107ba210d636be6d (diff)
Implement Display for Type and SExpr.
Diffstat (limited to 'src/lib/sexpr.rs')
-rw-r--r--src/lib/sexpr.rs11
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)));