Free v0.1.0

Source
Releases the block the builder owns.

Package: Text

Signature

func Free(self);

Remarks

There are no destructors, so ownership is released by hand, as it is for String::Free. It leaves an empty builder behind — Length and Capacity back to 0 — so a second call is a no-op, and the builder stays usable and will take a fresh block on the next append.

It is safe on a builder that owns nothing, which is what a builder is after IntoString has given its block away. Calling it there releases nothing and is not a double free.

To keep the block and only forget the contents, use Clear.

Example

import Text::StringBuilder;

func Main() -> int {
    var builder = StringBuilder::New();
    builder.Append("Rux");

    builder.Free();
    builder.IsEmpty(); // true

    builder.Append("again"); // fine -- the builder takes a new block
    builder.Free();
    return 0;
}

See also