aboutsummaryrefslogtreecommitdiff
path: root/src/sexp/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sexp/util.rs')
-rw-r--r--src/sexp/util.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/sexp/util.rs b/src/sexp/util.rs
new file mode 100644
index 0000000..a4e3ab4
--- /dev/null
+++ b/src/sexp/util.rs
@@ -0,0 +1,27 @@
+
+use crate::sexp::SExp;
+use crate::sexp::SLeaf;
+use crate::sexp::SExp::*;
+use crate::sexp::SLeaf::*;
+
+impl From<i32> for Box<SExp> {
+ fn from(int: i32) -> Self {
+ Box::new(Atom(Int(int)))
+ }
+}
+
+impl From<SLeaf> for Box<SExp> {
+ fn from(leaf: SLeaf) -> Self {
+ Box::new(Atom(leaf))
+ }
+}
+
+impl From<i32> for SLeaf {
+ fn from(int: i32) -> Self {
+ Int(int)
+ }
+}
+
+pub fn sexp(x: impl Into<Box<SExp>>, y: impl Into<Box<SExp>>) -> SExp {
+ SCons(x.into(), y.into())
+}