From bbd1364de53186af975ef1694fdc8451208ce626 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Mon, 19 Oct 2026 15:14:01 +0200 Subject: zilch: make object calls type agnostic --- src/zilch/Env/future.zig | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/zilch/Env/future.zig') diff --git a/src/zilch/Env/future.zig b/src/zilch/Env/future.zig index 1b44d85..f829009 100644 --- a/src/zilch/Env/future.zig +++ b/src/zilch/Env/future.zig @@ -13,15 +13,20 @@ pub fn Future(Kind: type) type { return .{ .future = future }; } - pub fn await(self: *const Self, env: *Env) !Kind { + pub fn await(self: *Self, env: *Env) !Kind { return self.future.await(env, Kind); } + + pub fn ignore(self: *Self, env: *Env) void { + return self.future.ignore(env); + } }; } pub const AnyFuture = union(enum) { const Self = @This(); + ignored: void, unresolved: struct { id: usize, value: *Env.Value, @@ -37,6 +42,7 @@ pub const AnyFuture = union(enum) { pub fn awaitAny(self: *Self, env: *Env) !Env.Value { defer self.* = undefined; switch (self.*) { + .ignored => @panic("awaited ignored value"), .err => |err| return err, .resolved => |result| return result, .unresolved => |result| { @@ -51,4 +57,13 @@ pub const AnyFuture = union(enum) { } } } + + pub fn ignore(self: *Self, env: *Env) void { + defer self.* = .ignored; + + switch (self.*) { + .unresolved => env.ignore(self), + else => {}, + } + } }; -- cgit v1.2.3-70-g09d2