Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

fromSlice

Public Function
std.zon.parse.fromSlice
pub fn fromSlice(
    T: type,
    gpa: Allocator,
    source: [:0]const u8,
    diag: ?*Diagnostics,
    options: Options,
) error

Parses the given slice as ZON.

Returns error.OutOfMemory on allocation failure, or error.ParseZon error if the ZON is invalid or can not be deserialized into type T.

When the parser returns error.ParseZon, it will also store a human readable explanation in diag if non null. If diag is not null, it must be initialized to .{}.

Asserts at compile time that the result type doesn't contain pointers. As such, the result doesn't need to be freed.

An allocator is still required for temporary allocations made during parsing.

Params

File

zon/parse.zig:262
262
263
264
265
266
267
268
269
270
271
pub fn fromSlice(
    T: type,
    gpa: Allocator,
    source: [:0]const u8,
    diag: ?*Diagnostics,
    options: Options,
) error{ OutOfMemory, ParseZon }!T {
    comptime assert(!requiresAllocator(T));
    return fromSliceAlloc(T, gpa, source, diag, options);
}