Function put [src]

key and value are copied into the EnvMap. On Windows key must be a valid WTF-8 string.

Prototype

pub fn put(self: *EnvMap, key: []const u8, value: []const u8) !void

Parameters

self: *EnvMapkey: []const u8value: []const u8

Source

pub fn put(self: *EnvMap, key: []const u8, value: []const u8) !void { assert(unicode.wtf8ValidateSlice(key)); const value_copy = try self.copy(value); errdefer self.free(value_copy); const get_or_put = try self.hash_map.getOrPut(key); if (get_or_put.found_existing) { self.free(get_or_put.value_ptr.*); } else { get_or_put.key_ptr.* = self.copy(key) catch |err| { _ = self.hash_map.remove(key); return err; }; } get_or_put.value_ptr.* = value_copy; }