Heh. Not knowing this I did the exact same boxing workaround once.
Yeah, this is the first solution people reach for, and as far as I can see, the docs steer you in that direction, so don’t blame yourself.
Permalink: src/bin/isol.rs in nfleet/isolation on GitHub
Would it ever be possible or desired for a variable to check for common traits as a secondary option when the types of the branches of its assignment don’t match up? In this case, inferring impl Read for that variable in your example.
I suspect this is not a desired feature primarily because it would lead to some very confusing errors and behavior, but it also seems more correct than having to go through an initial, superficially superfluous, binding process.
Esteban Kuber already told me that there’s some logic in the Rust compiler that will lead to nicer error messages in some cases already; just the (quite special) case I was showing in my blog wasn’t covered yet.