diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-06-08 18:29:12 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-08 18:29:12 -0400 |
| commit | d2278f21560014c635afe4bc247a9096ecb845de (patch) | |
| tree | e8bca82dcc8d09f6f287054b4c2ba171c190bf37 /lib/std/comptime_string_map.zig | |
| parent | 0ff5d7b24e2017199566d1bab75254fa5ef68611 (diff) | |
| parent | 05d284c842a5ba21cd836c2b212daa24227a9177 (diff) | |
| download | zig-d2278f21560014c635afe4bc247a9096ecb845de.tar.gz zig-d2278f21560014c635afe4bc247a9096ecb845de.zip | |
Merge pull request #5566 from ziglang/stage2-garbage-collect-decls
Stage2 garbage collect decls
Diffstat (limited to 'lib/std/comptime_string_map.zig')
| -rw-r--r-- | lib/std/comptime_string_map.zig | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/lib/std/comptime_string_map.zig b/lib/std/comptime_string_map.zig index 313f1fcdda..3021f6bc1e 100644 --- a/lib/std/comptime_string_map.zig +++ b/lib/std/comptime_string_map.zig @@ -17,18 +17,18 @@ pub fn ComptimeStringMap(comptime V: type, comptime kvs: var) type { }; var sorted_kvs: [kvs.len]KV = undefined; const lenAsc = (struct { - fn lenAsc(a: KV, b: KV) bool { + fn lenAsc(context: void, a: KV, b: KV) bool { return a.key.len < b.key.len; } }).lenAsc; for (kvs) |kv, i| { if (V != void) { - sorted_kvs[i] = .{.key = kv.@"0", .value = kv.@"1"}; + sorted_kvs[i] = .{ .key = kv.@"0", .value = kv.@"1" }; } else { - sorted_kvs[i] = .{.key = kv.@"0", .value = {}}; + sorted_kvs[i] = .{ .key = kv.@"0", .value = {} }; } } - std.sort.sort(KV, &sorted_kvs, lenAsc); + std.sort.sort(KV, &sorted_kvs, {}, lenAsc); const min_len = sorted_kvs[0].key.len; const max_len = sorted_kvs[sorted_kvs.len - 1].key.len; var len_indexes: [max_len + 1]usize = undefined; @@ -83,11 +83,11 @@ const TestEnum = enum { test "ComptimeStringMap list literal of list literals" { const map = ComptimeStringMap(TestEnum, .{ - .{"these", .D}, - .{"have", .A}, - .{"nothing", .B}, - .{"incommon", .C}, - .{"samelen", .E}, + .{ "these", .D }, + .{ "have", .A }, + .{ "nothing", .B }, + .{ "incommon", .C }, + .{ "samelen", .E }, }); testMap(map); @@ -99,11 +99,11 @@ test "ComptimeStringMap array of structs" { @"1": TestEnum, }; const map = ComptimeStringMap(TestEnum, [_]KV{ - .{.@"0" = "these", .@"1" = .D}, - .{.@"0" = "have", .@"1" = .A}, - .{.@"0" = "nothing", .@"1" = .B}, - .{.@"0" = "incommon", .@"1" = .C}, - .{.@"0" = "samelen", .@"1" = .E}, + .{ .@"0" = "these", .@"1" = .D }, + .{ .@"0" = "have", .@"1" = .A }, + .{ .@"0" = "nothing", .@"1" = .B }, + .{ .@"0" = "incommon", .@"1" = .C }, + .{ .@"0" = "samelen", .@"1" = .E }, }); testMap(map); @@ -115,11 +115,11 @@ test "ComptimeStringMap slice of structs" { @"1": TestEnum, }; const slice: []const KV = &[_]KV{ - .{.@"0" = "these", .@"1" = .D}, - .{.@"0" = "have", .@"1" = .A}, - .{.@"0" = "nothing", .@"1" = .B}, - .{.@"0" = "incommon", .@"1" = .C}, - .{.@"0" = "samelen", .@"1" = .E}, + .{ .@"0" = "these", .@"1" = .D }, + .{ .@"0" = "have", .@"1" = .A }, + .{ .@"0" = "nothing", .@"1" = .B }, + .{ .@"0" = "incommon", .@"1" = .C }, + .{ .@"0" = "samelen", .@"1" = .E }, }; const map = ComptimeStringMap(TestEnum, slice); @@ -142,11 +142,11 @@ test "ComptimeStringMap void value type, slice of structs" { @"0": []const u8, }; const slice: []const KV = &[_]KV{ - .{.@"0" = "these"}, - .{.@"0" = "have"}, - .{.@"0" = "nothing"}, - .{.@"0" = "incommon"}, - .{.@"0" = "samelen"}, + .{ .@"0" = "these" }, + .{ .@"0" = "have" }, + .{ .@"0" = "nothing" }, + .{ .@"0" = "incommon" }, + .{ .@"0" = "samelen" }, }; const map = ComptimeStringMap(void, slice); |
