This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| const Stuff = enum { zeroth, first, second, third, somethingElse }; | |
| const OtherStuff = enum { zeroth, first, second, third, somethingElse }; | |
| const EnumLookupError = error{InvalidName}; | |
| // convert a string into a enum field | |
| pub fn stringToEnum(comptime E: type, name: []const u8) EnumLookupError!E { | |
| inline for (std.meta.fields(E)) |e| { | |
| if (std.mem.eql(u8, name, e.name)) { |
NewerOlder