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.

declarations

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

meta.declarations
pub fn declarations(comptime T: type) []const [:0]const u8

File

lib/std/meta.zig:203

Code

pub fn declarations(comptime T: type) []const [:0]const u8 {
    return switch (@typeInfo(T)) {
        .@"struct" => |info| info.decl_names,
        .@"enum" => |info| info.decl_names,
        .@"union" => |info| info.decl_names,
        .@"opaque" => |info| info.decl_names,
        else => @compileError("Expected struct, enum, union, or opaque type, found '" ++ @typeName(T) ++ "'"),
    };
}