Capacity
Returns the current allocated capacity.
Module: Std
Signature
rux
func Capacity(self) -> uint;Returns
uint — the number of bytes the builder can hold before it must grow.
Description
Capacity is always greater than or equal to Length. The difference is the headroom available for appends before the next reallocation.
Example
rux
import Std::StringBuilder;
var sb = StringBuilder::WithCapacity(64);
sb.Append("hi");
// sb.Length() == 2, sb.Capacity() == 64See also
StringBuilder— the typeReserve— increase capacityShrink— release unused capacity