Skip to content

Links to code references showing common patterns in Zig

License

Notifications You must be signed in to change notification settings

pepomija/zig-patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Zig Patterns

A list of links to code references showing common patterns in Zig.

Goals

  • This document lives! Please make frequent updates.
  • Beware of bitrot! Look at the date of the entry and/or the version of zig referenced
  • Context Matters! Links to working code examples, for example the zig standard library, are preferred
  • Inclusive over canonical! Prefer showing different approaches side-by-side instead of annoiting a "best" approach.

Patterns

Arena Allocator

Closure

Comptime String Interning

Context

Custom Type Format

Default Argument Values

Deferred Resource Deinitialization

*0.13.0/lib/std/once.zig#L31

Diagnostics

Dynamic Dispatch (Fat Pointer)

Error Deferred Resource Deinitialization

*0.13.0/lib/std/tz.zig#L92

Field Parent Pointer

File Struct

Generic Function

Generic Type

Interfaces

Memory Pool - Fast Allocation

Static Dispatch (Tagged Union)

Static Error Absence Guarantee

*0.13.0/lib/std/hash_map.zig#L1563

Struct of Arrays

WaitGroup + ThreadPool

Web Request

References

Many thanks to all the blog posts that served as references

TODO

  • Support Patterns links to blog posts with links to working code on github

About

Links to code references showing common patterns in Zig

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published