diff --git a/pttodoer/src/main.rs b/pttodoer/src/main.rs index 8ffe24c..fb9af62 100644 --- a/pttodoer/src/main.rs +++ b/pttodoer/src/main.rs @@ -24,6 +24,40 @@ impl Task { assert!(false); false } + + fn get(&self, k: String) -> Option { + match self.0.get(k) { + Some(v) => Some( + serde_yaml::to_string(v) + .unwrap() + .trim() + .to_string() + ), + None => None, + } + } + + fn set(&mut self, k: String, v: String) { + self.0.insert( + serde_yaml::Value::String(k), + serde_yaml::Value::String(v) + ); + } +} + +#[cfg(test)] +mod test_task { + use super::*; + + #[test] + fn crud() { + let mut t = Task::new(); + t.set("k".to_string(), "v".to_string()); + assert_eq!( + t.get("k".to_string()), + Some("v".to_string()), + ); + } } #[derive(Debug)]