pub fn truncate(&mut self, len: usize) {
        unsafe {
            // drop any extra elements
            while len < self.len {
                // decrement len before the drop_in_place(), so a panic on Drop
                // doesn't re-drop the just-failed value.
                self.len -= 1;
                let len = self.len;
                ptr::drop_in_place(self.get_unchecked_mut(len));
            }
        }
    }
/// Shortens the vector, keeping the first `len` elements and dropping the rest.
Shortens the vector, keeping the first `len` elements and dropping the rest.
Shortens the vector keeping the first ` len ` elements and dropping the rest .
pub fn truncate(&mut self, len: usize) {
        unsafe {
            // drop any extra elements
            while len < self.len {
                // decrement len before the drop_in_place(), so a panic on Drop
                // doesn't re-drop the just-failed value.
                self.len -= 1;
                let len = self.len;
                ptr::drop_in_place(self.get_unchecked_mut(len));
            }
        }
    }
pub fn truncate ( & mut self , len : usize ) { unsafe { // drop any extra elements while len < self . len { // decrement len before the drop_in_place(), so a panic on Drop // doesn't re-drop the just-failed value. self . len -= 1 ; let len = self . len ; ptr :: drop_in_place ( self . get_unchecked_mut ( len ) ) ; } } }
Shortens the vector, keeping the first `len` elements and dropping the rest.
Shortens the vector keeping the first ` len ` elements and dropping the rest .
&mut self
len
usize
&mut self
len
usize