getSliceDefault
Parameters
Source
Implementation
pub fn getSliceDefault(self: *Data, gpa: std.mem.Allocator, key: Key, comptime S: type, default: []const @typeInfo(S).pointer.child) std.mem.Allocator.Error!Slice(S) {
const sentinel = @typeInfo(Slice(S)).pointer.sentinel();
const slice, const existing = try self.getOrPutSliceT(gpa, key, Slice(S), default.len, false);
if (!existing) {
@memcpy(slice, default);
if (sentinel) |s| slice[default.len] = s;
}
return slice;
}