summaryrefslogtreecommitdiff
path: root/rust/src/lambda.rs
blob: a24b031c9d775c15c6d674aed109e79f04e288bb (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
33
34
35
36
37
38
39
40
use std::{
    fmt::{self, Display},
    fs::read_to_string,
};

pub fn run(arg: &str) -> String {
    let content = read_to_string(arg).unwrap();
    let result = interpret(&content.to_string());

    result.to_string()
}

#[derive(Debug, PartialEq)]
pub enum Value {
    Num(i32),
}

impl Display for Value {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Value::Num(i) => write!(f, "{}", i),
        }
    }
}

fn interpret(_arg: &str) -> Value {
    Value::Num(1)
}

#[cfg(test)]
mod tests {
    use super::interpret;
    use super::Value::Num;

    #[test]
    fn it_works() {
        let result = interpret("1");
        assert_eq!(Num(1), result);
    }
}