struct ArgState [src]

Fields

next_arg: usize = 0
used_args: ArgSetType = 0
args_len: usize

Members

Source

pub const ArgState = struct { next_arg: usize = 0, used_args: ArgSetType = 0, args_len: usize, pub fn hasUnusedArgs(self: *@This()) bool { return @popCount(self.used_args) != self.args_len; } pub fn nextArg(self: *@This(), arg_index: ?usize) ?usize { const next_index = arg_index orelse init: { const arg = self.next_arg; self.next_arg += 1; break :init arg; }; if (next_index >= self.args_len) { return null; } // Mark this argument as used self.used_args |= @as(ArgSetType, 1) << @as(u5, @intCast(next_index)); return next_index; } }