aboutsummaryrefslogtreecommitdiff
path: root/src/zilch/Env/future.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/zilch/Env/future.zig')
-rw-r--r--src/zilch/Env/future.zig19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/zilch/Env/future.zig b/src/zilch/Env/future.zig
index 8b88cd8..1b44d85 100644
--- a/src/zilch/Env/future.zig
+++ b/src/zilch/Env/future.zig
@@ -3,7 +3,7 @@ const Env = @import("root.zig");
const z = @import("../root.zig");
-pub fn Future(comptime kind: Env.Value.Kind) type {
+pub fn Future(Kind: type) type {
return struct {
const Self = @This();
@@ -13,8 +13,8 @@ pub fn Future(comptime kind: Env.Value.Kind) type {
return .{ .future = future };
}
- pub fn await(self: *const Self, env: *Env) !kind.asType() {
- return self.future.await(env, kind);
+ pub fn await(self: *const Self, env: *Env) !Kind {
+ return self.future.await(env, Kind);
}
};
}
@@ -29,18 +29,9 @@ pub const AnyFuture = union(enum) {
resolved: Env.Value,
err: anyerror,
- pub fn await(self: *Self, env: *Env, comptime kind: Env.Value.Kind) !kind.asType() {
+ pub fn await(self: *Self, env: *Env, Kind: type) !Kind {
const result = try self.awaitAny(env);
-
- if (kind != result.kind) {
- std.log.err("unexpected {}, expected {}", .{ result.kind, kind });
- @panic("type error");
- }
-
- return switch (kind) {
- .string => result.value.string.ptr[0..result.value.string.len],
- else => @field(result.value, @tagName(kind)),
- };
+ return result.unwrap(Kind);
}
pub fn awaitAny(self: *Self, env: *Env) !Env.Value {