#Ideas on a "composite" generic.

1 messages · Page 1 of 1 (latest)

wraith siren
#

not sure I fully understand what your trying to do but I think I would just make a walker like this:
⁨⁨```rs
pub const Walker = struct {
stack: Stack(*const AstNode),

pub fn init(root: *const AstNode) Walker {
  // ...
}

pub fn next(self: *Walker) ?*const AstNode {
  // ...
}

};

and then smt like: (would probably look quite different)
⁨⁨```rs
var ctx: ValidationContext = .{};
var walker: Walker = .init(&root);

while (walker.next()) |node| {
    try CounterValidator.visit(&ctx, node);
    try AnonValidator.visit(&ctx, node);
}
```⁩⁩
hazy rock
#

I dont see how your code would get rid of the loops, i think it would just move them into the callbacks.