These are chat archives for rust-lang/rust
let mut x = 1; let y = &mut x; ley z0 = &y; let z1 = z0; // Now both `z0` and `z1` are references to mutable reference. let boom0 = *z0; let boom1 = *z1; // Whoa. `boom0` and `boom1` are two mutable references to the same location. // That's why this is not allowed.
&&mut Tis almost
&&Texcept that former is not covariant over
let z1 = z0a move and thus renders
*xdoes not give you ownership to whatever
Copy, then you may say that you get ownership of the copy
**x = 2will give you error if
x: &&mut T.
*(*x) = 2
(*x)tries to move (i.e. get ownership) the value referenced by
&&mut T, which I interpret as „I cannot mutate the borrowed reference, but I can mutate the value through the borrowed mutable reference“
&share &uniq T
&&mut Tmust give a
&mut T, and the latter would allow me to change the value.
let y = *x;or
foo(*x). If it's copiable
&mut T. yet copying is unavailable
&*operator of "reborrow as shared" and
&mut *as "reborrow as mutable".
*operator as "copy referenced value"
*x = ywhere it has different semantics
&*cannot be considered as a simple composition of
&is never the type of a value, but rather a type of a binding? I.e. a type of an lvalue?
Deserializetraits provided by the
serdeattributes you can customize the serialization as you need :-)
&*xare different things
&(*x)is the same as
derivemechanism is pretty verbose, though. (It's way way less verbose and error-prone than trying to do it yourself, but yeah, maybe there's still room for improvement.)