Namespaces

Functions

fn activeTag(u: anytype) Tag(@TypeOf(u))

Returns the active tag of a tagged union

fn alignment(comptime T: type) comptime_int

Returns the alignment of type T. Note that if T is a pointer or function type t…

Returns the alignment of type T. Note that if T is a pointer or function type the result is different than the one returned by @alignOf(T). If T is a pointer type the alignment of the type it points to is returned. If T is a function type the alignment a target-dependent value is returned.

fn containerLayout(comptime T: type) Type.ContainerLayout

No documentation provided.

fn declList(comptime Namespace: type, comptime Decl: type) []const *const Decl

Returns a slice of pointers to public declarations of a namespace.

fn declarationInfo(comptime T: type, comptime decl_name: []const u8) Type.Declaration

No documentation provided.

fn declarations(comptime T: type) []const Type.Declaration

Instead of this function, prefer to use e.g. @typeInfo(foo).Struct.decls dire…

Instead of this function, prefer to use e.g. @typeInfo(foo).Struct.decls directly when you know what kind of type it is.

fn eql(a: anytype, b: @TypeOf(a)) bool

Compares two of any type for equality. Containers are compared on a field-by-fie…

Compares two of any type for equality. Containers are compared on a field-by-field basis, where possible. Pointers are not followed.

fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int

Given a type and a name, return the field index according to source order. Retu…

Given a type and a name, return the field index according to source order. Returns null if the field is not found.

fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) {
    .Struct => Type.StructField,
    .Union => Type.UnionField,
    .ErrorSet => Type.Error,
    .Enum => Type.EnumField,
    else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
}

No documentation provided.

fn fieldNames(comptime T: type) *const [T.len][]const u8

No documentation provided.

fn fields(comptime T: type) switch (@typeInfo(T)) {
    .Struct => []const Type.StructField,
    .Union => []const Type.UnionField,
    .ErrorSet => []const Type.Error,
    .Enum => []const Type.EnumField,
    else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
}

No documentation provided.

fn globalOption(comptime name: []const u8, comptime T: type) ?T

TODO: https://github.com/ziglang/zig/issues/425

fn intToEnum(comptime EnumTag: type, tag_int: anytype) IntToEnumError!EnumTag

No documentation provided.

fn isError(error_union: anytype) bool

Returns whether error_union contains an error.

fn sentinel(comptime T: type) ?Elem(T)

Given a type which can have a sentinel e.g. [:0]u8, returns the sentinel value…

Given a type which can have a sentinel e.g. [:0]u8, returns the sentinel value, or null if there is not one. Types which cannot possibly have a sentinel will be a compile error.

fn stringToEnum(comptime T: type, str: []const u8) ?T

Returns the variant of an enum type, T, which is named str, or null if no …

Returns the variant of an enum type, T, which is named str, or null if no such variant exists.

fn tags(comptime T: type) *const [T.len]T

Given an enum or error set type, returns a pointer to an array containing all ta…

Given an enum or error set type, returns a pointer to an array containing all tags for that enum or error set.

Values

IntType
undefined
assumeSentinel
undefined
isTag
undefined
refAllDecls
undefined
tagName
undefined

Error Sets