Skip to content

Instantly share code, notes, and snippets.

@BarabasGitHub
Last active March 22, 2020 21:44
Show Gist options
  • Save BarabasGitHub/aab3c7daa0cced4a10fc66bf4525065b to your computer and use it in GitHub Desktop.
Save BarabasGitHub/aab3c7daa0cced4a10fc66bf4525065b to your computer and use it in GitHub Desktop.
Zig extension example
fn ArrayListExtension(comptime Type: type) type {
return struct {
const Self = std.ArrayList(Type);
pub fn ensureSize(self: *Self, size: usize) !void {
if (self.len < size) {
try self.resize(size);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment