pub fn reserve(&mut self, additional: usize) {
        let unused_bits: usize = self.capacity() - self.len();
        if additional > unused_bits {
            // Will never overflow because additional > current
            let needed_extra_bits = additional - unused_bits;
            // still need to check if we won't overflow the capacity() computation
            self.capacity()
                .checked_add(needed_extra_bits)
                .expect("Overflow detected");
            self.vec.reserve(blocks_required::<T>(needed_extra_bits));
        }
    }
/// Reserves capacity for at least `additional` more bits to be inserted in the Vob. The Vob
/// may reserve more space to avoid frequent reallocations. After calling `reserve`, capacity
/// will be greater than or equal to `self.len() + additional`. Does nothing if capacity is
/// already sufficient.
///
/// # Examples
/// ```
/// use vob::Vob;
/// let mut v = Vob::new();
/// v.reserve(1);
/// assert!(v.capacity() >= 1);
/// ```
Reserves capacity for at least `additional` more bits to be inserted in the Vob. The Vob
may reserve more space to avoid frequent reallocations. After calling `reserve`, capacity
will be greater than or equal to `self.len() + additional`. Does nothing if capacity is
already sufficient.
Reserves capacity for at least ` additional ` more bits to be inserted in the Vob . The Vob may reserve more space to avoid frequent reallocations . After calling ` reserve ` capacity will be greater than or equal to ` self . len () + additional ` . Does nothing if capacity is already sufficient .
pub fn reserve(&mut self, additional: usize) {
        let unused_bits: usize = self.capacity() - self.len();
        if additional > unused_bits {
            // Will never overflow because additional > current
            let needed_extra_bits = additional - unused_bits;
            // still need to check if we won't overflow the capacity() computation
            self.capacity()
                .checked_add(needed_extra_bits)
                .expect("Overflow detected");
            self.vec.reserve(blocks_required::<T>(needed_extra_bits));
        }
    }
pub fn reserve ( & mut self , additional : usize ) { let unused_bits : usize = self . capacity ( ) - self . len ( ) ; if additional > unused_bits { // Will never overflow because additional > current let needed_extra_bits = additional - unused_bits ; // still need to check if we won't overflow the capacity() computation self . capacity ( ) . checked_add ( needed_extra_bits ) . expect ( " " ) ; self . vec . reserve ( blocks_required :: < T > ( needed_extra_bits ) ) ; } }
Reserves capacity for at least `additional` more bits to be inserted in the Vob.
Reserves capacity for at least ` additional ` more bits to be inserted in the Vob .
&mut self
additional
usize
&mut self
additional
usize
examples
None