-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathis_empty.zig
29 lines (23 loc) · 877 Bytes
/
is_empty.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const zignite = @import("../zignite.zig");
const expect = @import("std").testing.expect;
const ConsumerType = @import("consumer_type.zig").ConsumerType;
test "is_epmty:" {
try expect(zignite.empty(i32).isEmpty());
try expect(zignite.range(i32, 0, 0).isEmpty());
try expect(!zignite.once(i32, 1).isEmpty());
try expect(!zignite.range(i32, 0, 2).isEmpty());
}
pub fn IsEmpty(comptime T: type) type {
return struct {
pub const Type = ConsumerType(T, @This(), bool);
pub const init = Type.State{};
pub fn next(event: Type.Event) Type.Action {
return switch (event.tag) {
._break => Type.Action._return(init, true),
._continue => Type.Action._await(init),
._yield => Type.Action._return(init, false),
};
}
pub const deinit = Type.nop;
};
}