Skip to main content

string_with_capacity

Function string_with_capacity 

Source
pub fn string_with_capacity(estimated_size: usize) -> String
Expand description

Pre-allocate a String with estimated capacity

This helper avoids reallocations by pre-allocating based on estimated size. Use this when building strings incrementally.

§Arguments

  • estimated_size - Estimated number of characters needed

§Returns

A String with pre-allocated capacity