Skip to content

Instantly share code, notes, and snippets.

@DutchGhost
Last active November 9, 2020 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DutchGhost/0205488fe900421cfdd2c60c7a82d4e8 to your computer and use it in GitHub Desktop.
Save DutchGhost/0205488fe900421cfdd2c60c7a82d4e8 to your computer and use it in GitHub Desktop.
Zutils
/// This piece of code is used whenever the number of iterations is comptime known.
/// `n` == iterations.
for ([_]u8{0} ** n) |_, i| {
}
/// This piece of code is used whenever the number of iterations is runtime known.
//// `n` == iterations.
for (@as([*]u0, undefined)[0..n]) |_, i| {
}
/// While using the above, beware of (#6947, #6944, #6937, #6936, #6934)
/// Use this piece of code when working with allocators
var specificAllocator = specificAllcator {};
const allocator = &specificAllocator.allocator;// <-- has type `*Allocator`, but the *pointer* itself is a const variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment