diff --git a/src/engine.rs b/src/engine.rs index 048514b..e936270 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -1,7 +1,7 @@ use crate::config::Engine; pub trait InputEngine { - fn get(&self) -> String; + fn get(&self) -> Vec; } pub fn build_input_engine(cfg: &Engine) -> Result, String> { @@ -14,11 +14,11 @@ pub fn build_input_engine(cfg: &Engine) -> Result, String> struct InputEngineStdin {} impl InputEngine for InputEngineStdin { - fn get(&self) -> String { + fn get(&self) -> Vec { let stdin = std::io::stdin(); let mut result = String::new(); stdin.read_line(&mut result).unwrap(); - return result.trim().to_string(); + return result.trim().chars().collect(); } } @@ -28,8 +28,8 @@ mod test_input { struct InputEngineTest {} impl InputEngine for InputEngineTest { - fn get(&self) -> String { - return "hello world".to_string(); + fn get(&self) -> Vec { + return "hello world".chars().collect(); } } @@ -40,12 +40,12 @@ mod test_input { } fn _test_input_engine_impl(engine: &dyn InputEngine) { - assert_eq!("hello world".to_string(), engine.get()); + assert_eq!("hello world".to_string(), engine.get().iter().cloned().collect::()); } } pub trait OutputEngine { - fn put(&self, v: String); + fn put(&self, v: Vec); } pub fn build_output_engine(cfg: &Engine) -> Result, String> { @@ -58,8 +58,8 @@ pub fn build_output_engine(cfg: &Engine) -> Result, String struct OutputEngineStdout {} impl OutputEngine for OutputEngineStdout { - fn put(&self, v: String) { - println!("{}", v); + fn put(&self, v: Vec) { + println!("{}", v.iter().cloned().collect::()); } } @@ -69,7 +69,7 @@ mod test_output { struct OutputEngineTest {} impl OutputEngine for OutputEngineTest { - fn put(&self, _v: String) { + fn put(&self, _v: Vec) { } } @@ -80,6 +80,6 @@ mod test_output { } fn _test_output_engine_impl(engine: &dyn OutputEngine) { - engine.put("teehee".to_string()); + engine.put("teehee".to_string().chars().collect()); } }