Right, ok, I see the issue now. First, let's cover mutable references. Those are guaranteed to be unique, and to provide a mutable reference to something, you must reborrow it, which leaves the original mutable reference inaccessible until the reborrowed mutable reference is no longer used.
The syntax for reborrowing a mutable reference is
&mut *xref. However a mutable reference is automatically reborrowed when no generics are involved. Your
test3 consumes the mutable reference because there are generics.
You can explicitly reborrow it, and it will work:
As for immutable references, those are not guaranteed to be unique, so they are copied instead of reborrowed, hence the issues go away.