aboutsummaryrefslogtreecommitdiff
path: root/src/hive_array.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/hive_array.zig')
-rw-r--r--src/hive_array.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/hive_array.zig b/src/hive_array.zig
index 39f10d324..cc032c44f 100644
--- a/src/hive_array.zig
+++ b/src/hive_array.zig
@@ -86,6 +86,14 @@ pub fn HiveArray(comptime T: type, comptime capacity: u16) type {
return self.allocator.create(T) catch unreachable;
}
+ pub fn tryGet(self: *This) !*T {
+ if (self.hive.get()) |value| {
+ return value;
+ }
+
+ return try self.allocator.create(T);
+ }
+
pub fn put(self: *This, value: *T) void {
if (self.hive.put(value)) return;