Data
Returns the pointer to the bytes written so far.
Module: Text
Signature
rux
func Data(self) -> *char8;Returns
A pointer to the first byte of the block, or null for a builder that has not taken one yet.
Unlike String::Data, this points at memory a later append may move: growing the block reallocates it. Do not hold the pointer across an Append, a Reserve, a Grow, or a Shrink — read it again afterwards.
Only the first Length bytes have been written; the rest of the capacity is uninitialized. There is no null terminator, so pair the pointer with Length.
Example
rux
import Text::StringBuilder;
var builder = StringBuilder::New();
builder.Append("Rux");
let bytes = builder.Data(); // valid for Length() bytes
builder.Append(" rocks"); // may reallocate -- `bytes` is now suspect
builder.Free();See also
StringBuilder— the builder typeLength— how many of the bytes have been writtenToString— take a copy that will not moveString::Data— the same pointer on a string, which never moves