And keep the mut
-or-not bindings? I admit I've never spent a lot of time considering that alternative universe. Does it go like so?
-
&mut
coeres to&uniq
or&
-
&uniq
coerces to&
-
&uniq
has the same move semantics and aliasing guarantees as&mut
- You can create a
&uniq
from a non-mut
variable - You can get a
&'short mut
out of a&'short uniq &'long mut
And then you could write
impl Env<'_> {
fn helper(&uniq Self) {
// ...
*env.errors += 1;
}
fn foo(/* not mut */ env: Env<'_>) {
env.helper();
}
But helper
couldn't replace all of env
or get a &mut
to any field?
Interesting to think about. I guess it is a more-immutable-reference than &
.