Just completed Linked List task in Zig track.
I’m not sure is it for Zig-variant of this task only but API that is expected to be implemented feels like completely artificial and not that of a real world data structure (even putting aside Zig memory management specifics):
pub fn push(self: *LinkedList(T), node: *Node) void
pub fn pop(self: *LinkedList(T)) ?*Node
pub fn shift(self: *LinkedList(T)) ?*Node
pub fn unshift(self: *LinkedList(T), node: *Node) void
pub fn delete(self: *LinkedList(T), node: *Node) void
adding/deleting Nodes and not data itself not make much sense. Implementing delete even doesn’t actually require to find node in a list - you can just do it using next and prev values of node itself.
Moreover, this task could be good exercise to teach correct memory management in Zig, helping to learn idiomatic ways of working with heap (as passing allocator in every method that can allocate on heap - as per “no hidden allocations” rule).
There are some good exercises that took Zig specifics to the count and I learned some good lessons solving them. Linked List can be one of them.