1use crate::prelude::*;
2use std::fmt;
3
4#[derive(Clone)]
6pub struct SumObj {
7 pub param: String,
8 pub start: Box<Obj>,
9 pub end: Box<Obj>,
10 pub body: Box<Obj>,
11}
12
13impl SumObj {
14 pub fn new(param: String, start: Obj, end: Obj, body: Obj) -> Self {
15 SumObj {
16 param,
17 start: Box::new(start),
18 end: Box::new(end),
19 body: Box::new(body),
20 }
21 }
22}
23
24impl fmt::Display for SumObj {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 write!(
27 f,
28 "{}{}{}{}{}{}{}{}{}{}{}{}{}",
29 SUM,
30 LEFT_BRACE,
31 self.param,
32 COMMA,
33 " ",
34 self.start,
35 COMMA,
36 " ",
37 self.end,
38 COMMA,
39 " ",
40 self.body,
41 RIGHT_BRACE,
42 )
43 }
44}