|
|
|
|
|
by TheDong
998 days ago
|
|
It 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. |
|