Skip to main content

vec_with_capacity_cautious

Function vec_with_capacity_cautious 

Source
pub(crate) fn vec_with_capacity_cautious<Element>(
    hint: Option<usize>,
) -> Vec<Element>
Expand description

Safer version of Vec::with_capacity that uses size_hint_cautious to prevent overflow when calculating the capacity.

Implemented to address crashes due to capacity overflow, e.g., GHSA-7gcf-g7xr-8hxj