pub fn shrink_to_fit(&mut self) {
        // The capacity is never less than the length, and there's nothing to do when
        // they are equal, so we can avoid the panic case in `RawVec::shrink_to_fit`
        // by only calling it with a greater capacity.
        if self.capacity() > self.len {
            self.buf.shrink_to_fit(self.len);
        }
    }
Shortens the vector, keeping the first `len` elements and dropping
the rest.

If `len` is greater than the vector's current length, this has no
effect.

The [`drain`] method can emulate `truncate`, but causes the excess
elements to be returned instead of dropped.

Note that this method has no effect on the allocated capacity
of the vector.

# Examples

Truncating a five element vector to two elements:

```
let mut vec = vec![1, 2, 3, 4, 5];
vec.trunc
benchmarks/haystacks/code/rust-library.rs