summaryrefslogtreecommitdiff
path: root/rust/src/lambda.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/lambda.rs')
-rw-r--r--rust/src/lambda.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/rust/src/lambda.rs b/rust/src/lambda.rs
new file mode 100644
index 0000000..a24b031
--- /dev/null
+++ b/rust/src/lambda.rs
@@ -0,0 +1,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);
+ }
+}