Esc

toml_encode

procedureextensionsince 0.36.1Source
  • macOS: toml_encode works on macOS
  • Linux: toml_encode works on Linux
  • Windows: toml_encode works on Windows
  • Wasm: toml_encode works on Wasm

Encodes the value value points to as TOML, like to_toml without copying it first. Returns owned text to free, or an empty string and the error.

Signature

toml_encode :: (
    value: *$T,
    options := Toml_Options.{}
) -> (string, Toml_Error)
Example↗
Point :: struct {
    x: float64;
    y: float64;
}

p := Point.{ 1, 2.5 };
text, error := toml_encode(*p);
assert(error.kind == .NONE && text == "x = 1.0\ny = 2.5\n");
free(text);

See also