more test learn that borrowing means free trait gets

master
Bel LaPointe 2023-03-16 15:00:37 -06:00
parent ba66176d9d
commit 877ec04cbe
2 changed files with 34 additions and 0 deletions

33
src/engine.rs Normal file
View File

@ -0,0 +1,33 @@
pub trait InputEngine {
fn get(&self) -> String;
}
struct InputEngineStdin {}
impl InputEngine for InputEngineStdin {
fn get(&self) -> String {
return "hello world".to_string();
}
}
#[cfg(test)]
mod test {
use super::*;
struct InputEngineTest {}
impl InputEngine for InputEngineTest {
fn get(&self) -> String {
return "hello world".to_string();
}
}
#[test]
fn test_input_engine_impl() {
let input_engine_test = InputEngineTest{};
_test_input_engine_impl(&input_engine_test);
}
fn _test_input_engine_impl(engine: &dyn InputEngine) {
assert_eq!("hello world".to_string(), engine.get());
}
}

View File

@ -1,4 +1,5 @@
pub mod config; pub mod config;
pub mod engine;
fn main() { fn main() {
let cfg = config::build_config(); let cfg = config::build_config();