• Stars
    star
    150
  • Rank 247,323 (Top 5 %)
  • Language
    Zig
  • License
    MIT License
  • Created 12 months ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Common Zig patterns for you and your friends :)

Zig Design Patterns

About

This repository contains examples of common design patterns found in Zig's standard library and many community projects.

Note that copying (one of) these patterns verbatim into your project may not be useful; it's important to weigh the pros and cons of different patterns. If you come from another language, especially a non-systems one, you'll often find that the more unfamiliar ideas featured here may be more useful.

For example, I've seldom used interface-like patterns when designing systems in Zig, despite using such patterns dozens of times a day at work writing TypeScript or Go.

Examples

All examples are annotated with comments including recommendations regarding when to use the patterns shown.

Example How to run
@fieldParentPtr zig build field_parent_ptr
Inline Switch zig build inline_switch
MultiArrayList zig build multi_array_list
Type Function zig build type_function
Virtual Table zig build vtable

License

MIT