tiny.preserves.toText
Defined in tiny.preserves.
Returns value as text, allocated with alloc.
Source
Source: lib/preserves/src/text/format.zig:32
zig
/// Returns `value` as text, allocated with `alloc`. The JSON encoder calls it for a text spelling/// of each dictionary key other than a string or symbol, and code that logs or prints any value/// calls it for a readable form. The caller owns the bytes and frees them with `alloc`, and on/// error the call frees what it wrote.////// Atoms other than byte strings are spelled as the text writer spells them. A byte string is/// written as `#"…"`, with `\x` escapes for bytes outside printable ASCII and for `"` and `\`. The/// discard pattern is written `<_>`, a capture or bind as its wire form, and a rest pattern as/// `[prefix … . rest]`. An embedded value from `parse` is written `#:` and its value, and any other/// embedded value `#:` and its pointer in decimal. Sets and dictionaries are written in the order/// they are stored, with dictionary entries separated by a space.////// The call returns `error.DuplicateSetElement` or `error.DuplicateDictionaryKey` for a set with/// two equal elements or a dictionary with two equal keys, and `error.OutOfMemory`. Writing a/// capture or bind frees parts of `value` when its pattern holds a set, a record label, a/// dictionary key or a big integer. Running out of memory while it writes a capture or bind leaks/// the wire record built so far.pub fn toText(alloc: Allocator, value: Value) ![]const u8 { var buf: ArrayList = .empty; errdefer buf.deinit(alloc); try writeValue(alloc, &buf, value); return buf.toOwnedSlice(alloc);}Source: lib/preserves/src/root.zig:302
zig
pub const toText = text.toText;Also reachable as
Audit
| Definitions | 1 |
|---|---|
| Public names | 2 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |