Skip to main content

format_with_capacity

Function format_with_capacity 

pub fn format_with_capacity(capacity: usize, args: Arguments<'_>) -> String
Expand description

Format args into a new string with the requested initial capacity.

This is useful when the caller can cheaply determine the rendered length from its inputs. Formatting happens once and the string does not reallocate as long as capacity is large enough.

§Panics

Panics if a formatting trait implementation supplied through args returns fmt::Error, matching format!.