Created
June 16, 2019 04:00
-
-
Save marler8997/21be72451adea88560b0b13c67de0e86 to your computer and use it in GitHub Desktop.
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
const std = @import("std"); | |
pub fn copyVarargs(array: var, args: ...) void { | |
comptime var i = 0; | |
inline while (i < args.len) : (i += 1) array[i] = args[i]; | |
} | |
pub fn allocVarargs(comptime T: type, allocator: *std.mem.Allocator, args: ...) ![]T { | |
var array = try allocator.alloc(T, args.len); | |
copyVarargs(array, args); | |
return array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment