aboutsummaryrefslogtreecommitdiff
path: root/src/sexp/util.rs
blob: c31358f5cf37db3716c65ff784432b482e6737af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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 scons(x: impl Into<Box<SExp>>, y: impl Into<Box<SExp>>) -> SExp {
    SCons(x.into(), y.into())
}