MiahDrao97/iter_z: Generic Iterator for Zig
This library provides a generic iterator interface with queries/transformations inspired by System.Linq in C#. You can instantiate Iter(T)
from slices, linked lists, multi-array lists, or simply any type that defines a next()
method. You can even define your own implementation just as easily by implementing the AnonymousIterable(T)
interface. (NOTE: Instantiating from linked lists is only available on the main branch since they changed shortly after Zig 0.14.0.)
I’ve been playing with Zig for a little over a year now, and writing this library has been a fun way to explore comptime, idiomatic Zig programming, and just how interfaces and closures work in general. It’s been a massive learning experience and really opened my mind into how much goes into engineering things like System.Linq (I believe the actual System.Linq leverages expression trees optimized by the .NET runtime; really wild stuff).
I’ve observed that Zig is more “ad hoc” in its approach to iterators, so this library may very well be bringing a tank to a knife fight. But that’s the fun of pet projects. However, if you simply wanna write queries quickly and your memory footprint is less of an immediate concern, this would do the job. The various revisions in this library have been focused around reducing allocations and improving the API. Would love feedback.