tiny.preserves.parsedEmbeddedOps
Defined in embedded_mod.
Returns one table whose equality, hash and order read each payload as a pointer to a Value and call eql, hash and compare on it.
Source
Source: lib/preserves/src/embedded.zig:136
zig
/// Returns one table whose equality, hash and order read each payload as a pointer to a `Value` and/// call `eql`, `hash` and `compare` on it. The text parser, the JSON reader and `observeRecord`/// call it when they wrap a value as an embedded payload. The table is one constant per `Value`/// type, so payloads built by the text parser, the JSON reader and `observeRecord` compare with/// each other. `toText` checks for this table to print the payload as a value.pub fn parsedEmbeddedOps(comptime Value: type) *const SemanticOps { const Impl = struct { fn eql(a: *anyopaque, b: *anyopaque) bool { const va: *const Value = @ptrCast(@alignCast(a)); const vb: *const Value = @ptrCast(@alignCast(b)); return va.*.eql(vb.*); } fn hash(ptr: *anyopaque) u64 { const v: *const Value = @ptrCast(@alignCast(ptr)); return v.*.hash(); } fn order(a: *anyopaque, b: *anyopaque) std.math.Order { const va: *const Value = @ptrCast(@alignCast(a)); const vb: *const Value = @ptrCast(@alignCast(b)); return va.*.compare(vb.*); } const ops: SemanticOps = .{ .eql = &eql, .hash = &hash, .order = &order, }; }; return &Impl.ops;}Source: lib/preserves/src/root.zig:162
zig
pub const parsedEmbeddedOps = embedded_mod.parsedEmbeddedOps;Audit
| Definitions | 1 |
|---|---|
| Public names | 2 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |