Shrink
Releases unused capacity.
Module: Std
Signature
rux
func Shrink(self);Description
Reallocates the buffer down to exactly Length bytes, freeing any slack between the length and the capacity. Does nothing if the builder is already full or empty. Useful before holding a builder around for a long time, though most code converts to a String instead.
Example
rux
import Std::StringBuilder;
var sb = StringBuilder::WithCapacity(1024);
sb.Append("short");
sb.Shrink(); // capacity drops to 5See also
StringBuilder— the typeReserve— the opposite directionIntoString— also trims slack while converting