DVUI

getPtrDefault

Parameters

#
self:*Data
*Data
gpa:std.mem.Allocator
std.mem.Allocator
key:Key
Key
T:type
type
default:T
T

Source

Implementation

#
pub fn getPtrDefault(self: *Data, gpa: std.mem.Allocator, key: Key, comptime T: type, default: T) std.mem.Allocator.Error!*T {
    const value, const existing = try self.getOrPutT(gpa, key, T);
    if (!existing) value.* = default;
    return value;
}