more test learn that borrowing means free trait gets
parent
ba66176d9d
commit
877ec04cbe
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue