-
Notifications
You must be signed in to change notification settings - Fork 6
Meta type ‣ isFieldTypedArray(T, name)
Chung Leong edited this page Oct 25, 2025
·
1 revision
Determine whether a struct/union field should be a typed array.
Usage:
const std = @import("std");
const Struct = struct {
field: []const u8 = "hello",
};
pub const structure: Struct = .{};
const module = @This();
pub const @"meta(zigar)" = struct {
pub fn isFieldTypedArray(comptime T: type, comptime name: std.meta.FieldEnum(T)) bool {
return T == Struct and name == .field;
}
};import { structure } from './meta-type-typed-array-example-2.zig';
console.log(structure.field);Uint8Array(5) [ 104, 101, 108, 108, 111 ]
Arguments:
-
T- Struct/union type in question -
name- Name of the field represented by an enum