Meta type ‣ isDeclString(T, name) - chung-leong/zigar GitHub Wiki

Determine whether a decl should be a text string.

Usage:

const std = @import("std");

pub const declaration: []const u8 = "hello";

const module = @This();
pub const @"meta(zigar)" = struct {
    pub fn isDeclString(comptime T: type, comptime name: std.meta.DeclEnum(T)) bool {
        return T == module and name == .declaration;
    }
};
import { declaration } from './meta-type-string-example-1.zig';

console.log(declaration);
hello

Arguments:

  • T: type - Namespace containing the decl
  • name: std.meta.DeclEnum(T): - Name of the decl represented by an enum

Meta types | Text string