API Reference — PolyNode, ItemHandle, Slot
New to the concepts? See Building Blocks — PolyNode
first.
This page covers the actual Zig types and functions.
const polynode = @import("matryoshka").polynode;
// typical usage:
var slot: polynode.Slot = &event.poly; // slot holds the node
slot = null; // slot is empty
Types
pub const PolyTag = struct { _: u8 = 0 };
pub const PolyNode = struct {
node: std.DoublyLinkedList.Node,
tag: *const anyopaque,
};
pub const ItemHandle = *PolyNode;
pub const Slot = ?ItemHandle;
-
PolyNodeis the type every Item embeds. Itstagis a unique address that identifies which type a node lives inside (see Step 2). -
ItemHandleis a pointer to that embedded field — the only thing Matryoshka moves. Slotis where a handle lives while it is yours.
Next: reset / is_linked.