#[macro_use] extern crate mock; trait BestTrait { fn compute(&self, usize, Vec) -> String; fn other(&self, String) -> Result; } #[test] fn readme() { let m = mock!(BestTrait); mock!(m.compute(usize, Vec) -> String { "success".to_string() }); // leave other() unimplemented use_trait(m); } fn use_trait(best: &BestTrait) { assert_eq!("success".to_string(), best.compute(3, vec![1, 4, 1, 5])); }