pub fn insert(self: *BufSet, value: []const u8) !void self: *BufSetvalue: []const u836
37
38
39
40
41
42
43
44 pub fn insert(self: *BufSet, value: []const u8) !void {
const gop = try self.hash_map.getOrPut(value);
if (!gop.found_existing) {
gop.key_ptr.* = self.copy(value) catch |err| {
_ = self.hash_map.remove(value);
return err;
};
}
}
Insert an item into the BufSet. The item will be copied, so the caller may delete or reuse the passed string immediately.