DoxigAlpha

insert

Insert an item into the BufSet. The item will be copied, so the caller may delete or reuse the passed string immediately.

Function parameters

Parameters

#
self:*BufSet
value:[]const u8

A BufSet is a set of strings.

Types

#
BufSet
A BufSet is a set of strings.

Source

Implementation

#
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;
        };
    }
}