Open
Description
The ability to specify that an impl Trait
return type only implements a trait if some other bound is met.
trait Foo {
fn foo<T>(x: T) -> impl Debug + (Clone iff T: Clone);
}
As @Kimundi observed in the original impl Trait
proposal, this common pattern can be seen in Rust's Iterator
trait. Methods like chain
return a type that is only Clone
if Self: Clone
and Other: Clone
.
There's some discussion of this in the expanded impl Trait
RFC, but I haven't seen any fully-fledged proposals for this yet.