Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

putMove

Public Function
std.buf_map.BufMap.putMove
pub fn putMove(self: *BufMap, key: []u8, value: []u8) !void

Same as put but the key and value become owned by the BufMap rather than being copied. If putMove fails, the ownership of key and value does not transfer.

Params

  • self: *BufMap
  • key: []u8
  • value: []u8

File

buf_map.zig:36
36
37
38
39
40
41
42
43
44
    pub fn putMove(self: *BufMap, key: []u8, value: []u8) !void {
        const get_or_put = try self.hash_map.getOrPut(key);
        if (get_or_put.found_existing) {
            self.free(get_or_put.key_ptr.*);
            self.free(get_or_put.value_ptr.*);
            get_or_put.key_ptr.* = key;
        }
        get_or_put.value_ptr.* = value;
    }