Meta type ‣ isFieldString(T, name) - chung-leong/zigar GitHub Wiki
Determine whether a struct/union field should be a text string.
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 isFieldString(comptime T: type, comptime name: std.meta.FieldEnum(T)) bool {
return T == Struct and name == .field;
}
};
import { structure } from './meta-type-string-example-2.zig';
console.log(structure.field);
[ 104, 101, 108, 108, 111 ]
Arguments:
T- Struct/union type in questionname- Name of the field represented by an enum