1. 16
  1. 5
    1. 4

      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.

      1. 2

        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.

        1. 1

          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.