blob: ce6de5d500b14d470cf245d68461d3e4a366dbf9 (
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
28
29
30
31
32
|
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())
}
pub fn var(name: &str) -> SExp {
Atom(Var(name.to_string()))
}
|