Skip to content

Commit

Permalink
std.build.Builder: fix for Allocator changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GethDW committed Nov 30, 2022
1 parent 71038c4 commit 7369114
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/std/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -523,21 +523,21 @@ pub const Builder = struct {
const name = self.dupe(name_raw);
const description = self.dupe(description_raw);
const type_id = comptime typeToEnum(T);
const enum_options = if (type_id == .@"enum") blk: {
const enum_options: ?ArrayList([]const u8) = if (type_id == .@"enum") blk: {
const fields = comptime std.meta.fields(T);
var options = ArrayList([]const u8).initCapacity(self.allocator, fields.len) catch unreachable;

inline for (fields) |field| {
options.appendAssumeCapacity(field.name);
}

break :blk options.toOwnedSlice();
break :blk options;
} else null;
const available_option = AvailableOption{
.name = name,
.type_id = type_id,
.description = description,
.enum_options = enum_options,
.enum_options = if (enum_options) |options| options.items else null,
};
if ((self.available_options_map.fetchPut(name, available_option) catch unreachable) != null) {
panic("Option '{s}' declared twice", .{name});
Expand Down

0 comments on commit 7369114

Please sign in to comment.