#Generics
4 posts tagged Generics. All posts
Iterators in Go: range over functions and the iter packageWrite Go iterators with iter.Seq and Seq2: generators, tree walks, early break and the yield contract, slices.Collect and maps.Keys, and merging with iter.Pull.
Builders and the typestate pattern in RustFrom a plain Rust builder to one where missing required fields are compile errors, then a PhantomData state machine, with the trade-offs of encoding state in types.
Python typing with Protocols and the PEP 695 generic syntaxStructural typing with typing.Protocol, the limits of runtime_checkable, Python 3.12's generic syntax and type statement, checked with mypy and Pyright.
Go generics in practice: constraints, generic types and when to skip themGo 1.25 type parameters: constraints with ~ and unions, cmp.Ordered, a generic Set, Map and Filter helpers, slices and maps, and when an interface is simpler.
© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)