Yes, but rarely. For example &mut &[u8]
could be used to "consume" parts of the slice (replacing it with a shorter subslice of itself), which is used in the Read
implementation for &[u8]
. Though to be fair, if this wasn't done to conform to the existing, more general trait inferface here, one would typically avoid such API.
A major issue with &mut &..
is that when you mutate some Copy
-able type, users of the API can easily mess up and call the method only on a copy of the thing that they actually meant to mutate. This is the reason why e. g. iterator generally shouldn't also implement Copy
.