#fit #shrink #recursion #calls #container #elements #collection

shrink-to-fit

Recursively calls shrink_to_fit on all elements of the container

11 releases

new 0.2.10 Feb 8, 2025
0.2.9 Feb 7, 2025
0.1.0 Feb 6, 2025

#1009 in Data structures

Download history 173/week @ 2025-02-01

173 downloads per month
Used in 4 crates (3 directly)

Apache-2.0

11KB
236 lines

Shrink-to-fit trait for collections.

This crate provides a ShrinkToFit trait that can be used to shrink-to-fit collections.

Examples

use shrink_to_fit::ShrinkToFit;

let mut vec = Vec::with_capacity(100);
vec.push(1);
vec.push(2);
vec.push(3);
vec.shrink_to_fit();
assert_eq!(vec.len(), 3);
assert_eq!(vec.capacity(), 3);

Dependencies

~0–500KB