-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix regression mocking "impl trait" for generic traits
The regression was probably introduced by PR #86
- Loading branch information
Showing
2 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// vim: tw=80 | ||
|
||
use mockall::*; | ||
|
||
trait MyTrait<T> {} | ||
|
||
struct MyStruct<T>(T); | ||
impl<T> MyTrait<T> for MyStruct<T> {} | ||
|
||
mock!{ | ||
Foo { | ||
fn foo<R: 'static>(&self) -> impl MyTrait<R>; | ||
} | ||
} | ||
|
||
#[test] | ||
fn returning() { | ||
let mut mock = MockFoo::new(); | ||
mock.expect_foo::<u32>().returning(|| Box::new(MyStruct(42u32))); | ||
let _mto: Box<dyn MyTrait<u32>> = mock.foo(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters