From dcf3e32d9ce4ff46db02f0f3b29b4e1dc6642f03 Mon Sep 17 00:00:00 2001 From: Snir Yehuda Date: Wed, 25 Jun 2025 22:19:26 +0300 Subject: [PATCH 1/2] enhance fetchPut documentation --- lib/std/hash_map.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index fb9b9f269df1..2a4a978eb460 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -344,11 +344,13 @@ pub fn HashMap( } /// Inserts a new `Entry` into the hash map, returning the previous one, if any. + /// If there is a previous Entry, the key parameter is not used. pub fn fetchPut(self: *Self, key: K, value: V) Allocator.Error!?KV { return self.unmanaged.fetchPutContext(self.allocator, key, value, self.ctx); } /// Inserts a new `Entry` into the hash map, returning the previous one, if any. + /// If there is a previous Entry, the key parameter is not used. /// If insertion happens, asserts there is enough capacity without allocating. pub fn fetchPutAssumeCapacity(self: *Self, key: K, value: V) ?KV { return self.unmanaged.fetchPutAssumeCapacityContext(key, value, self.ctx); From 8fe10f05f0610a20cf04c1eb63c91e31e3f5b89c Mon Sep 17 00:00:00 2001 From: Snir Yehuda Date: Wed, 25 Jun 2025 22:28:01 +0300 Subject: [PATCH 2/2] refine comment --- lib/std/hash_map.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index 2a4a978eb460..7058a9292a92 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -344,13 +344,13 @@ pub fn HashMap( } /// Inserts a new `Entry` into the hash map, returning the previous one, if any. - /// If there is a previous Entry, the key parameter is not used. + /// If there is a previous Entry, the `key` parameter is not used. pub fn fetchPut(self: *Self, key: K, value: V) Allocator.Error!?KV { return self.unmanaged.fetchPutContext(self.allocator, key, value, self.ctx); } /// Inserts a new `Entry` into the hash map, returning the previous one, if any. - /// If there is a previous Entry, the key parameter is not used. + /// If there is a previous Entry, the `key` parameter is not used. /// If insertion happens, asserts there is enough capacity without allocating. pub fn fetchPutAssumeCapacity(self: *Self, key: K, value: V) ?KV { return self.unmanaged.fetchPutAssumeCapacityContext(key, value, self.ctx);