DoxigAlpha

requiresAllocator

Function parameters

Parameters

#
T:type

Configuration for the runtime parser.

Types

#
Options
Configuration for the runtime parser.
Diagnostics
Information about the success or failure of a parse.

Parses the given slice as ZON.

Functions

#
fromSlice
Parses the given slice as ZON.
fromZoir
Like `fromSlice`, but operates on `Zoir` instead of ZON source.
fromZoirNode
Like `fromZoir`, but the parse starts on `node` instead of root.
free
Frees ZON values.

Source

Implementation

#
fn requiresAllocator(T: type) bool {
    _ = valid_types;
    return switch (@typeInfo(T)) {
        .pointer => true,
        .array => |array| return array.len > 0 and requiresAllocator(array.child),
        .@"struct" => |@"struct"| inline for (@"struct".fields) |field| {
            if (requiresAllocator(field.type)) {
                break true;
            }
        } else false,
        .@"union" => |@"union"| inline for (@"union".fields) |field| {
            if (requiresAllocator(field.type)) {
                break true;
            }
        } else false,
        .optional => |optional| requiresAllocator(optional.child),
        .vector => |vector| return vector.len > 0 and requiresAllocator(vector.child),
        else => false,
    };
}