Last active
March 22, 2020 21:44
-
-
Save BarabasGitHub/aab3c7daa0cced4a10fc66bf4525065b to your computer and use it in GitHub Desktop.
Zig extension example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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