pub fn reserve(&mut self, additional: usize) {
        let remaining = self.capacity() - self.len(); // this can't overflow
        if remaining < additional {
            let min_cap = self.len().checked_add(additional).expect("reserve overflow");
            let raw_cap = self.resize_policy.raw_capacity(min_cap);
            self.resize(raw_cap);
        } else if self.table.tag() && remaining <= self.len() {
            // Probe sequence is too long and table is half full,
            // resize early to reduce probing length.
            let new_capacity = self.table.capacity() * 2;
            self.resize(new_capacity);
        }
    }
/// Reserves capacity for at least `additional` more elements to be inserted
/// in the `HashMap`. The collection may reserve more space to avoid
/// frequent reallocations.
///
/// # Panics
///
/// Panics if the new allocation size overflows [`usize`].
///
Reserves capacity for at least `additional` more elements to be inserted
in the `HashMap`. The collection may reserve more space to avoid
frequent reallocations.
Reserves capacity for at least ` additional ` more elements to be inserted in the ` HashMap ` . The collection may reserve more space to avoid frequent reallocations .
pub fn reserve(&mut self, additional: usize) {
        let remaining = self.capacity() - self.len(); // this can't overflow
        if remaining < additional {
            let min_cap = self.len().checked_add(additional).expect("reserve overflow");
            let raw_cap = self.resize_policy.raw_capacity(min_cap);
            self.resize(raw_cap);
        } else if self.table.tag() && remaining <= self.len() {
            // Probe sequence is too long and table is half full,
            // resize early to reduce probing length.
            let new_capacity = self.table.capacity() * 2;
            self.resize(new_capacity);
        }
    }
pub fn reserve ( & mut self , additional : usize ) { let remaining = self . capacity ( ) - self . len ( ) ; // this can't overflow if remaining < additional { let min_cap = self . len ( ) . checked_add ( additional ) . expect ( " " ) ; let raw_cap = self . resize_policy . raw_capacity ( min_cap ) ; self . resize ( raw_cap ) ; } else if self . table . tag ( ) && remaining <= self . len ( ) { // Probe sequence is too long and table is half full, // resize early to reduce probing length. let new_capacity = self . table . capacity ( ) * 2 ; self . resize ( new_capacity ) ; } }
Reserves capacity for at least `additional` more elements to be inserted
in the `HashMap`.
Reserves capacity for at least ` additional ` more elements to be inserted in the ` HashMap ` .
&mut self
additional
usize
&mut self
additional
usize
panics
Panics if the new allocation size overflows [`usize`].
Panics if the new allocation size overflows [ ` usize ` ] .