| ... | @@ -42,6 +42,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def | ... | @@ -42,6 +42,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def |
| 42 | /// The result array is in the same order as the input. | 42 | /// The result array is in the same order as the input. |
| 43 | pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumField) []const E { | 43 | pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumField) []const E { |
| 44 | comptime { | 44 | comptime { |
| | 45 | @setEvalBranchQuota(@typeInfo(E).@"enum".fields.len + eval_branch_quota_cushion); |
| 45 | var result: [fields.len]E = undefined; | 46 | var result: [fields.len]E = undefined; |
| 46 | for (&result, fields) |*r, f| { | 47 | for (&result, fields) |*r, f| { |
| 47 | r.* = @enumFromInt(f.value); | 48 | r.* = @enumFromInt(f.value); |
| ... | @@ -53,7 +54,7 @@ pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumFi | ... | @@ -53,7 +54,7 @@ pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumFi |
| 53 | | 54 | |
| 54 | /// Returns the set of all named values in the given enum, in | 55 | /// Returns the set of all named values in the given enum, in |
| 55 | /// declaration order. | 56 | /// declaration order. |
| 56 | pub fn values(comptime E: type) []const E { | 57 | pub inline fn values(comptime E: type) []const E { |
| 57 | return comptime valuesFromFields(E, @typeInfo(E).@"enum".fields); | 58 | return comptime valuesFromFields(E, @typeInfo(E).@"enum".fields); |
| 58 | } | 59 | } |
| 59 | | 60 | |