Creates a [`CowSlice`] with an allocation of `vec`. None of `vec`'s elements are kept.
(mut vec: Vec<T>)
| 339 | impl<'borrowed, T> CowSlice<'borrowed, T> { |
| 340 | /// Creates a [`CowSlice`] with an allocation of `vec`. None of `vec`'s elements are kept. |
| 341 | pub fn with_allocation(mut vec: Vec<T>) -> Self { |
| 342 | vec.clear(); |
| 343 | Self { |
| 344 | slice: [].as_slice().into(), |
| 345 | vec, |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | /// Converts a [`CowSlice`] into its internal allocation. The [`Vec<T>`] is empty. |
| 350 | pub fn into_allocation(mut self) -> Vec<T> { |