A list of links to code references showing common patterns in Zig.
- This document lives! It needs frequent updates to stay relevant.
- 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.
*0.13.0/lib/std/hash_map.zig#L1563
const std = @import("std");
fn doThing(str: []const u8) void {
const Case = enum { fizz, buzz, @"fizz buzz" };
const case = std.meta.stringToEnum(Case, str) orelse return;
switch (case) {
.fizz => {},
.buzz => {},
.@"fizz buzz" => {},
}
}Many thanks to all the blog posts that served as references
- Support Patterns links to blog posts with links to working code on github