///! Test that generic traits can be mocked. use mockers::Scenario; use mockers_derive::mocked; #[mocked] pub trait A { fn put(&self, t: T); } #[test] fn test_generic_trait() { let scenario = Scenario::new(); let (mock, handle) = scenario.create_mock_for::>(); scenario.expect(handle.put(2).and_return(())); mock.put(2); } #[mocked] pub trait B { type Item; fn put(&self, t: T) -> Self::Item; } #[test] fn test_generic_trait_with_type_member() { let scenario = Scenario::new(); let (mock, handle) = scenario.create_mock_for::>(); scenario.expect(handle.put(2).and_return(4)); assert_eq!(4, mock.put(2)); }