Skip to content

enhance fetchPut documentation #24268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/std/hash_map.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down