diff options
Diffstat (limited to 'src/sexp')
-rw-r--r-- | src/sexp/display.rs | 1 | ||||
-rw-r--r-- | src/sexp/mod.rs | 2 | ||||
-rw-r--r-- | src/sexp/step.rs | 17 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/sexp/display.rs b/src/sexp/display.rs index 96ce435..57d1b50 100644 --- a/src/sexp/display.rs +++ b/src/sexp/display.rs @@ -26,6 +26,7 @@ impl fmt::Display for SLeaf { Int(x) => x.to_string(), Var(s) => s.to_string(), Quote => "quote".to_string(), + Vector => "vector".to_string(), Nil => "()".to_string(), }) } diff --git a/src/sexp/mod.rs b/src/sexp/mod.rs index 60dd3b0..3f17b79 100644 --- a/src/sexp/mod.rs +++ b/src/sexp/mod.rs @@ -27,7 +27,9 @@ pub enum SLeaf { Or, Not, Xor, + Quote, + Vector, Int(i32), True, diff --git a/src/sexp/step.rs b/src/sexp/step.rs index d66b1bd..535b183 100644 --- a/src/sexp/step.rs +++ b/src/sexp/step.rs @@ -220,6 +220,23 @@ impl SExp { /// Ok(scons(Quote, scons(1, scons(2, Nil)))) /// ); /// ``` + /// + /// **Vectors** + /// + /// The same as quotes functionally, but they require + /// the elements to be of the same type. + /// ```rust + /// use myslip::sexp::{SExp::*, SLeaf::*, util::*}; + /// assert_eq!( + /// scons(Vector, scons(1, scons(2, Nil))).step(), + /// Ok(scons(Vector, scons(1, scons(2, Nil)))) + /// ); + /// assert_eq!( + /// scons(Vector, scons( + /// scons(Sub, scons(2, scons(1, Nil))), + /// scons(2, Nil))).step(), + /// Ok(scons(Vector, scons(1, scons(2, Nil)))) + /// ); pub fn step(self) -> Result<Self, String> { match self { |