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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use std::fmt::{Debug, Display};
use std::ops::Deref;

/// Pretty printable with Display trait.
pub struct Processed<T> {
	/// Processed data of the Munyo language
    pub result: Vec<T>,
}

impl<T> Processed<T> {
	/// Creates Processed
    pub fn new(result: Vec<T>) -> Self {
        Self { result }
    }
}

impl<T: Display> Display for Processed<T> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        for item in &self.result {
            writeln!(f, "{}", item)?;
        }
        Ok(())
    }
}

impl<T: Debug> Debug for Processed<T> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        for item in &self.result {
            writeln!(f, "{:?}", item)?;
        }
        Ok(())
    }
}

impl<T: Clone> Clone for Processed<T> {
    fn clone(&self) -> Self {
        Self {
            result: self.result.clone(),
        }
    }
}

impl<T> Deref for Processed<T>{
    type Target = [T];

    fn deref(&self) -> &Self::Target {
        &self.result
    }
}