Esc

to_toml

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

Writes a struct as a TOML document: key/value lines first, then [table] and [[array of tables]] headers for struct fields; null pointers are omitted. Honors the notes of from_toml and the output limits of options. Free the text with free.

Signature

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

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

See also