Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support specific impls #274

Merged
merged 3 commits into from
Apr 25, 2021
Merged

Support specific impls #274

merged 3 commits into from
Apr 25, 2021

Conversation

asomers
Copy link
Owner

@asomers asomers commented Apr 24, 2021

A specific impl is an implementation of a trait on a generic struct with specific generic parameters, like impl Foo for Bar<i32> {}

Issue #271

asomers added 3 commits April 23, 2021 21:23
Previously when mock! encountered a trait impl (`impl Foo for Bar`) it
would construct a new `Trait` and mock that using the same path used by
`#[automock]`.  But ever since 0.9.0, it's easier to simply mock the
ItemImpl directly.  This removes a bunch of internal code, but has no
user-visible changes.
Mockall is picker now about how you mock a trait on a generic struct.
Previously you could usually omit the generics.  Now, they're required.
i.e.,
```rust
mock!{
    MyStruct<T: Bounds> {...}
    impl Foo for MyStruct {...}
}
```
should now be written as
```rust
mock!{
    MyStruct<T: Bounds> {...}
    impl<T: Bounds> Foo for MyStruct<T> {...}
}
```
A specific impl is an implementation of a trait on a generic struct with
specific generic parameters, like `impl Foo for Bar<i32> {}`

Issue #271
@asomers asomers merged commit 8c5c8ab into master Apr 25, 2021
@asomers asomers deleted the specific_impl branch April 25, 2021 22:54
asomers added a commit that referenced this pull request Jul 2, 2021
Must staticize return values for trait methods with generic arguments,
as long as the mock object itself is not generic.

This was a regression introduced by PR #274, and released in v0.10.0. It
only affects trait methods, not struct methods.

Fixes #298
asomers added a commit that referenced this pull request Jul 2, 2021
Must staticize return values for trait methods with generic arguments,
as long as the mock object itself is not generic.

This was a regression introduced by PR #274, and released in v0.10.0. It
only affects trait methods, not struct methods.

Fixes #298
asomers added a commit that referenced this pull request Jul 2, 2021
Must staticize return values for trait methods with generic arguments,
as long as the mock object itself is not generic.

This was a regression introduced by PR #274, and released in v0.10.0. It
only affects trait methods, not struct methods.

Fixes #298
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant