aboutsummaryrefslogtreecommitdiff
path: root/lib/std/hash_map.zig
diff options
context:
space:
mode:
authorMatthew Lugg <mlugg@mlugg.co.uk>2024-09-12 19:50:38 +0100
committerGitHub <noreply@github.com>2024-09-12 19:50:38 +0100
commit0001f91e4e1e51cd64cdd5c0a21451c8bad67233 (patch)
tree9c3efb262890fa76a9b1d02c694dadad11c316f4 /lib/std/hash_map.zig
parentb95e0e09dcbe4ca948fd4098a8e3a4d90df9cb22 (diff)
parent9271a89c65967ff0fed7011b4195abdd0f9195eb (diff)
downloadzig-0001f91e4e1e51cd64cdd5c0a21451c8bad67233.tar.gz
zig-0001f91e4e1e51cd64cdd5c0a21451c8bad67233.zip
Merge pull request #21287 from linusg/deprecated-default-init
Replace deprecated default initializations with decl literals
Diffstat (limited to 'lib/std/hash_map.zig')
-rw-r--r--lib/std/hash_map.zig14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig
index 54b85e4b3d..9c436320b7 100644
--- a/lib/std/hash_map.zig
+++ b/lib/std/hash_map.zig
@@ -401,7 +401,7 @@ pub fn HashMap(
@compileError("Context must be specified! Call initContext(allocator, ctx) instead.");
}
return .{
- .unmanaged = .{},
+ .unmanaged = .empty,
.allocator = allocator,
.ctx = undefined, // ctx is zero-sized so this is safe.
};
@@ -410,7 +410,7 @@ pub fn HashMap(
/// Create a managed hash map with a context
pub fn initContext(allocator: Allocator, ctx: Context) Self {
return .{
- .unmanaged = .{},
+ .unmanaged = .empty,
.allocator = allocator,
.ctx = ctx,
};
@@ -691,7 +691,7 @@ pub fn HashMap(
pub fn move(self: *Self) Self {
self.unmanaged.pointer_stability.assertUnlocked();
const result = self.*;
- self.unmanaged = .{};
+ self.unmanaged = .empty;
return result;
}
@@ -1543,7 +1543,7 @@ pub fn HashMapUnmanaged(
return self.cloneContext(allocator, @as(Context, undefined));
}
pub fn cloneContext(self: Self, allocator: Allocator, new_ctx: anytype) Allocator.Error!HashMapUnmanaged(K, V, @TypeOf(new_ctx), max_load_percentage) {
- var other = HashMapUnmanaged(K, V, @TypeOf(new_ctx), max_load_percentage){};
+ var other: HashMapUnmanaged(K, V, @TypeOf(new_ctx), max_load_percentage) = .empty;
if (self.size == 0)
return other;
@@ -1572,7 +1572,7 @@ pub fn HashMapUnmanaged(
pub fn move(self: *Self) Self {
self.pointer_stability.assertUnlocked();
const result = self.*;
- self.* = .{};
+ self.* = .empty;
return result;
}
@@ -2360,7 +2360,7 @@ test "removeByPtr 0 sized key" {
}
test "repeat fetchRemove" {
- var map = AutoHashMapUnmanaged(u64, void){};
+ var map: AutoHashMapUnmanaged(u64, void) = .empty;
defer map.deinit(testing.allocator);
try map.ensureTotalCapacity(testing.allocator, 4);
@@ -2384,7 +2384,7 @@ test "repeat fetchRemove" {
}
test "getOrPut allocation failure" {
- var map: std.StringHashMapUnmanaged(void) = .{};
+ var map: std.StringHashMapUnmanaged(void) = .empty;
try testing.expectError(error.OutOfMemory, map.getOrPut(std.testing.failing_allocator, "hello"));
}