{"title":"Zig Snippets: string to enum","author_url":"https://blog.hatena.ne.jp/agtn/","blog_title":"\u53f3\u4e0a\u2197","provider_name":"Hatena Blog","url":"https://agtn.hatenablog.com/entry/2022/08/31/000000_1","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fagtn.hatenablog.com%2Fentry%2F2022%2F08%2F31%2F000000_1\" title=\"Zig Snippets: string to enum - \u53f3\u4e0a\u2197\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","width":"100%","height":"190","provider_url":"https://hatena.blog","type":"rich","published":"2022-08-31 00:00:00","blog_url":"https://agtn.hatenablog.com/","description":"Zig \u3067 []const u8 \u304b\u3089 enum \u306b\u5909\u63db\u3059\u308b \u305f\u3076\u3093 builtin \u306b\u3082\u5b58\u5728\u3057\u306a\u3044\u6c17\u304c\u3059\u308b\uff1f\u306e\u3067\u3059\u304c\u3001\u9006 (enum \u2192 string) \u306f @tagName \u3067\u53ef\u80fd\u306a\u306e\u3067\u3001 @typeInfo \u3084 inline for \u3092\u304f\u307f\u3042\u308f\u305b\u3066\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 const std = @import(\"std\"); const E = enum { a, b }; fn strToE(s: []const u8) ?E { inline for (@typeInfo(E).Enum.fields) |f| { if (std.mem.eql(u8, f.name, s\u2026","author_name":"agtn","image_url":null,"categories":[],"version":"1.0"}