Comment

Comment by kajika91

Couldn't we have a function to return the data like this?

  pub const SinglyLinkedList(comptime T: type) type {
    return struct {
      first: ?*Node = null,

      pub const Node = struct {
        next: ?*Node = null,
      };

      const Self = @This(); 
      pub fn data(self: Self) *T {
        return @fieldParentPtr("node", self);
      }
  };
parent kajika91 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton