add(zig-interface): dependency to check interface contracts at comptime
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 53s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 53s
The described interfaces for `Widget` and `Layout` are now defined and correspondingly checked at comptime.
This commit is contained in:
@@ -11,14 +11,13 @@ const Key = terminal.Key;
|
||||
|
||||
const log = std.log.scoped(.layout_padding);
|
||||
|
||||
pub fn Layout(comptime Event: type, comptime Renderer: type) type {
|
||||
pub fn Layout(comptime Event: type, comptime Element: type, comptime Renderer: type) type {
|
||||
if (!isTaggedUnion(Event)) {
|
||||
@compileError("Provided user event `Event` for `Layout(comptime Event: type)` is not of type `union(enum)`.");
|
||||
@compileError("Provided user event `Event` for `Layout(comptime Event: type, comptime Element: type, comptime Renderer: type)` is not of type `union(enum)`.");
|
||||
}
|
||||
if (!isTaggedUnion(Element)) {
|
||||
@compileError("Provided type `Element` for `Layout(comptime Event: type, comptime Element: type, comptime Renderer: type)` is not of type `union(enum)`.");
|
||||
}
|
||||
const Element = union(enum) {
|
||||
layout: @import("../layout.zig").Layout(Event, Renderer),
|
||||
widget: @import("../widget.zig").Widget(Event, Renderer),
|
||||
};
|
||||
const Events = std.ArrayList(Event);
|
||||
return struct {
|
||||
size: terminal.Size = undefined,
|
||||
|
||||
Reference in New Issue
Block a user