Pre-RFC: returning automatically generating impl Trait

This has come up before, often called "enum impl trait". Searching for that will find a bunch of threads, such as Extending `impl Trait` to allow multiple return types

I think this will be the biggest conceptual sticking point (as opposed to implementation-detail difficulties). Many will argue that they would like this to be opt-in, I suspect. (One possible argument: This adds a branch to every use of the returned value, which is something that shouldn't be added invisibly.)

One hard question that might force it to have an opt-in marker of some sort: how would it pick between doing the compiler-generated enum and doing a coercion, if one is available?

5 Likes