Zig 0.17.0-dev (Split by item)

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 library itself.

fromSlice

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.

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

File

lib/std/zon/parse.zig:263

Code

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);
}