asomers / mockall

A powerful mock object library for Rust
Apache License 2.0
1.5k stars 62 forks source link

Add a test for the Return Position Impl Trait in Trait feature #526

Closed asomers closed 10 months ago

asomers commented 10 months ago

In nightly compilers, it's now possible to return impl Trait in a trait method. Mockall needs nothing new to support this. The existing "deimplify" strategy, already used for inherent methods, works for trait methods too.

The generated code will still return Box<dyn Trait> instead of impl Trait. We can't easily change that because the generated code also includes things like Fn() -> impl Trait, and Rust does not yet allow "impl Trait" as a return type for closures. The generated code also includes things like Into<impl Trait>, which makes even less sense.

https://rust-lang.github.io/rfcs/3425-return-position-impl-trait-in-traits.html