-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Description
(Sub-issue of #149488. Related to future work from rust-lang/rfcs#3721.)
As currently implemented on nightly, if you want to convert a bunch of stuff to a particular error, you use something like
try bikeshed Result<_, io::Error> { … }That might sometimes be useful if we actually want to write the ok type, but often it seems like it's just _, because of course the body of the block ends up having specified that type anyway.
In terms of the try_trait_v2 model, however, it would in a sense make more sense to residual type. That doesn't have the "extra" type of the ok part, since it's arguably not the point.
But in the implementations of the traits that doesn't really make much sense, because writing out the residual type isn't actually any easier:
try bikeshed Result<!, io::Error> { … }But maybe introducing a something like a family type would work? (Could use that instead of "residual" in the naming too.)
If that became a common thing to use and name, we could do something like
try bikeshed anyhow::Family { … }Though that's not necessarily any different from type Family = Result<!, anyhow::Result>;.
We could also imagine taking something that's not a complete type, like have try bikeshed anyhow::Result taking a type constructor instead, though I think that's currently unprecedented in Rust so might be too weird.