3 ms·
What is “&**self” called?
by qprofyeh 3y ago
What is “&**self” called?
- gdprrrr 3y agoIt reborrows `*self` als a slice. I prefer The Methode `as_slice` which does the same.
- TheDong 3y agoIt is so simple it does not have a name. It is simply a double deref + borrow. Since "deref" can be implemented differently for each type, you cannot know what it does in general, but in this case '*Vec<T>' turns it into a '[T]'. If you compile in release mode, all of the following implementations of 'clone' will emit identical assembly: <[T]>::to_vec(&**self) <[T]>::to_vec(&self[..]) <[T]>::to_vec(self.as_slice()) self.as_slice().to_vec() The stdlib picked the coolest looking one. Can't fault them for that.
- zdimension 3y agoHonestly I'd have preferred `.as_slice().to_vec()`