Function putMove [src]
Same as put but the key and value become owned by the EnvMap rather
than being copied.
If putMove fails, the ownership of key and value does not transfer.
On Windows key must be a valid WTF-8 string.
Prototype
pub fn putMove(self: *EnvMap, key: []u8, value: []u8) !void
Parameters
self: *EnvMap
key: []u8
value: []u8
Source
pub fn putMove(self: *EnvMap, key: []u8, value: []u8) !void {
assert(unicode.wtf8ValidateSlice(key));
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;
}