diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-07-04 22:25:49 +0000 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-07-05 21:11:42 +0000 |
| commit | 3a89f214aa672c5844def1704845ad38ea60bdcd (patch) | |
| tree | 0beea13a328bf74507509bb249211406e11bdb09 /doc | |
| parent | 3c8b13d998c5c58c8171d36d7506ea3a181d0db9 (diff) | |
| download | zig-3a89f214aa672c5844def1704845ad38ea60bdcd.tar.gz zig-3a89f214aa672c5844def1704845ad38ea60bdcd.zip | |
update more HashMap API usage
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/docgen.zig | 2 | ||||
| -rw-r--r-- | doc/langref.html.in | 14 |
2 files changed, 4 insertions, 12 deletions
diff --git a/doc/docgen.zig b/doc/docgen.zig index 7886c7cc90..e2acfae768 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -392,7 +392,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { .n = header_stack_size, }, }); - if (try urls.put(urlized, tag_token)) |entry| { + if (try urls.fetchPut(urlized, tag_token)) |entry| { parseError(tokenizer, tag_token, "duplicate header url: #{}", .{urlized}) catch {}; parseError(tokenizer, entry.value, "other tag here", .{}) catch {}; return error.ParseError; diff --git a/doc/langref.html.in b/doc/langref.html.in index dfbb93decf..d7b9de3c6e 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -5363,11 +5363,11 @@ const std = @import("std"); const assert = std.debug.assert; test "turn HashMap into a set with void" { - var map = std.HashMap(i32, void, hash_i32, eql_i32).init(std.testing.allocator); + var map = std.AutoHashMap(i32, void).init(std.testing.allocator); defer map.deinit(); - _ = try map.put(1, {}); - _ = try map.put(2, {}); + try map.put(1, {}); + try map.put(2, {}); assert(map.contains(2)); assert(!map.contains(3)); @@ -5375,14 +5375,6 @@ test "turn HashMap into a set with void" { _ = map.remove(2); assert(!map.contains(2)); } - -fn hash_i32(x: i32) u32 { - return @bitCast(u32, x); -} - -fn eql_i32(a: i32, b: i32) bool { - return a == b; -} {#code_end#} <p>Note that this is different from using a dummy value for the hash map value. By using {#syntax#}void{#endsyntax#} as the type of the value, the hash map entry type has no value field, and |
