From 94e0afff42bb49163e9af6cfc3e796bdb5a9aa99 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Mon, 31 May 2021 13:58:11 -0700 Subject: [PATCH] gen- add stringToEnum that prints missing values --- scripts/_common.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/_common.zig b/scripts/_common.zig index 7a61ab8d3e552eace9879e351a3fd0f70196e6c1..4e8821bc57073cd451f874f62e06c14713646bfc 100644 --- a/scripts/_common.zig +++ b/scripts/_common.zig @@ -67,3 +67,9 @@ pub fn Main(comptime T: type) type { } }; } + +pub fn stringToEnum(comptime T: type, str: []const u8) !void { + if (std.meta.stringToEnum(T, str)) |_| {} else { + std.log.warn("{s} is not part of the type {s}", .{ str, @typeName(T) }); + } +} -- 2.54.0