Clarify parameter and argument compatibility

Although this is unambiguous after understanding it, I feel it could use a bit more clarity. The first time I read this, I was mostly confused. Many times, without even knowing. Since there was an assignment going on (`*input = val;`), I thought the compatibility was referring to THAT assignment. This proposal makes it clear, especially to new readers, where exactly this compatibility lies.
pull/516/head
Emmanuel Amoah 3 weeks ago committed by GitHub
parent 5b3a9d084c
commit cbb626add7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -118,7 +118,7 @@ This is a classic use-after-free bug!
Our first instinct might be to blame the `assign` impl, but there's really nothing wrong here.
It shouldn't be surprising that we might want to assign a `T` into a `T`.
The problem is that we cannot assume that `&mut &'static str` and `&mut &'b str` are compatible.
The problem is that we cannot assume that `&mut &'static str` (the `&mut hello` argument) and `&mut &'b str` (the `input` parameter) are compatible.
This means that `&mut &'static str` **cannot** be a *subtype* of `&mut &'b str`,
even if `'static` is a subtype of `'b`.

Loading…
Cancel
Save