use std::fmt::Display; use mockers::Scenario; use mockers_derive::mocked; #[test] fn test_impl_trait_boxed() { #[mocked(TraitMock)] trait Trait { fn foo(&self) -> impl Display; } let scenario = Scenario::new(); let (mock, handle) = scenario.create_mock::(); scenario.expect(handle.foo().and_return(Box::new(42))); assert_eq!(mock.foo().to_string(), "42"); } #[test] fn test_impl_trait_sized() { #[mocked(TraitMock)] trait Trait { #[mocked(return_type=u32)] fn foo(&self) -> impl Sized; } let scenario = Scenario::new(); let (mock, handle) = scenario.create_mock::(); scenario.expect(handle.foo().and_return(42)); assert_eq!(mock.foo().to_string(), "42"); }