pub fn resize (&mut self, capacity: usize) {
        let mut new_buf = Vec::with_capacity(capacity+1);
        let to_be_skipped = if self.len()>capacity{
            self.len() - capacity
        } else {
            0
        };
        new_buf.extend(self.drain().skip(to_be_skipped).map(|x| ManuallyDrop::new(x)));
        let elem_num = new_buf.len();
        for _ in 0..capacity -new_buf.len() + 1{
            new_buf.push(ManuallyDrop::new(unsafe{uninitialized()}));
        }
        new_buf.shrink_to_fit();
        self.buffer = new_buf.into_boxed_slice();
        self.start = 0;
        self.end = elem_num;
    }
/**
    Changes internal size of the buffer.

    # Example

    ```
    use advanced_collections::circular_buffer::CircularBuffer;

    fn main(){
        let mut cb:CircularBuffer<i32> = CircularBuffer::new(5);
        assert_eq!(cb.capacity(), 5);
        cb.resize(7);
        assert_eq!(cb.capacity(), 7);

    }
    ```
    */
Changes internal size of the buffer.
Changes internal size of the buffer .
pub fn resize (&mut self, capacity: usize) {
        let mut new_buf = Vec::with_capacity(capacity+1);
        let to_be_skipped = if self.len()>capacity{
            self.len() - capacity
        } else {
            0
        };
        new_buf.extend(self.drain().skip(to_be_skipped).map(|x| ManuallyDrop::new(x)));
        let elem_num = new_buf.len();
        for _ in 0..capacity -new_buf.len() + 1{
            new_buf.push(ManuallyDrop::new(unsafe{uninitialized()}));
        }
        new_buf.shrink_to_fit();
        self.buffer = new_buf.into_boxed_slice();
        self.start = 0;
        self.end = elem_num;
    }
pub fn resize ( & mut self , capacity : usize ) { let mut new_buf = Vec :: with_capacity ( capacity + 1 ) ; let to_be_skipped = if self . len ( ) > capacity { self . len ( ) - capacity } else { 0 } ; new_buf . extend ( self . drain ( ) . skip ( to_be_skipped ) . map ( | x | ManuallyDrop :: new ( x ) ) ) ; let elem_num = new_buf . len ( ) ; for _ in 0 .. capacity - new_buf . len ( ) + 1 { new_buf . push ( ManuallyDrop :: new ( unsafe { uninitialized ( ) } ) ) ; } new_buf . shrink_to_fit ( ) ; self . buffer = new_buf . into_boxed_slice ( ) ; self . start = 0 ; self . end = elem_num ; }
Changes internal size of the buffer.
Changes internal size of the buffer .
&mut self
capacity
usize
&mut self
capacity
usize
example
```
use advanced_collections::circular_buffer::CircularBuffer.

fn main(){
let mut cb:CircularBuffer = CircularBuffer::new(5);
assert_eq!(cb.capacity(), 5);
cb.resize(7);
assert_eq!(cb.capacity(), 7).


` ` ` use advanced_collections :: circular_buffer :: CircularBuffer . fn main () { let mut cb : CircularBuffer = CircularBuffer :: new ( 5 ) ; assert_eq! ( cb . capacity () 5 ) ; cb . resize ( 7 ) ; assert_eq! ( cb . capacity () 7 ) .