From bf4632c461508de5202db98d25cd7ec06787c8dd Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sat, 26 Jul 2025 10:52:03 +0300 Subject: Created necessary data structures and utilities for integers and their operations; added tests for them --- src/sexp/util.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/sexp/util.rs (limited to 'src/sexp/util.rs') 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 for Box { + fn from(int: i32) -> Self { + Box::new(Atom(Int(int))) + } +} + +impl From for Box { + fn from(leaf: SLeaf) -> Self { + Box::new(Atom(leaf)) + } +} + +impl From for SLeaf { + fn from(int: i32) -> Self { + Int(int) + } +} + +pub fn sexp(x: impl Into>, y: impl Into>) -> SExp { + SCons(x.into(), y.into()) +} -- cgit v1.2.3