Commit 4b657d2de5
Changed files (1)
lib
std
lib/std/Io.zig
@@ -781,24 +781,14 @@ pub fn Future(Result: type) type {
/// Idempotent.
pub fn cancel(f: *@This(), io: Io) Result {
const any_future = f.any_future orelse return f.result;
- io.vtable.cancel(
- io.userdata,
- any_future,
- if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug
- .of(Result),
- );
+ io.vtable.cancel(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result));
f.any_future = null;
return f.result;
}
pub fn await(f: *@This(), io: Io) Result {
const any_future = f.any_future orelse return f.result;
- io.vtable.await(
- io.userdata,
- any_future,
- if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug
- .of(Result),
- );
+ io.vtable.await(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result));
f.any_future = null;
return f.result;
}
@@ -1162,9 +1152,9 @@ pub fn async(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(functio
var future: Future(Result) = undefined;
future.any_future = io.vtable.async(
io.userdata,
- if (@sizeOf(Result) == 0) &.{} else @ptrCast((&future.result)[0..1]), // work around compiler bug
+ @ptrCast((&future.result)[0..1]),
.of(Result),
- if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug
+ @ptrCast((&args)[0..1]),
.of(Args),
TypeErased.start,
);
@@ -1181,12 +1171,7 @@ pub fn go(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function))
@call(.auto, function, args_casted.*);
}
};
- io.vtable.go(
- io.userdata,
- if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug
- .of(Args),
- TypeErased.start,
- );
+ io.vtable.go(io.userdata, @ptrCast((&args)[0..1]), .of(Args), TypeErased.start);
}
pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp {