tiny.preserves.assertIsDomain
Defined in domain.
Stops compilation unless D declares public functions named eql, order, deinit and clone.
Source
Source: lib/preserves/src/domain.zig:32
zig
/// Stops compilation unless `D` declares public functions named `eql`, `order`, `deinit` and/// `clone`. Code that writes a generic over `Value` calls it first, as `Value` and every generic of/// the package do, so a type of embedded values that breaks the rules fails. The check tests that/// the names exist and reads no signature. The error names the missing function and the signature/// the package calls: `eql(a: Self, b: Self) bool`, `order(a: Self, b: Self) std.math.Order`,/// `deinit(self: *Self, allocator: Allocator) void` and/// `clone(self: Self, allocator: Allocator) !Self`.pub fn assertIsDomain(comptime D: type) void { if (!@hasDecl(D, "eql")) { @compileError("Domain " ++ @typeName(D) ++ " is missing `pub fn eql(a: Self, b: Self) bool`"); } if (!@hasDecl(D, "order")) { @compileError("Domain " ++ @typeName(D) ++ " is missing `pub fn order(a: Self, b: Self) std.math.Order`"); } if (!@hasDecl(D, "deinit")) { @compileError("Domain " ++ @typeName(D) ++ " is missing `pub fn deinit(self: *Self, allocator: Allocator) void`"); } if (!@hasDecl(D, "clone")) { @compileError("Domain " ++ @typeName(D) ++ " is missing `pub fn clone(self: Self, allocator: Allocator) !Self`"); }}Source: lib/preserves/src/root.zig:135
zig
pub const assertIsDomain = domain.assertIsDomain;Audit
| Definitions | 1 |
|---|---|
| Public names | 2 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |