Changed to fix local variable is never mutated
This commit is contained in:
parent
7989929d05
commit
3797c1473b
6
args.zig
6
args.zig
|
@ -401,7 +401,7 @@ fn parseInt(comptime T: type, str: []const u8) !T {
|
|||
base1024 = true;
|
||||
}
|
||||
if (buf.len != 0) {
|
||||
var pow: u3 = switch (buf[buf.len - 1]) {
|
||||
const pow: u3 = switch (buf[buf.len - 1]) {
|
||||
'k', 'K' => 1, //kilo
|
||||
'm', 'M' => 2, //mega
|
||||
'g', 'G' => 3, //giga
|
||||
|
@ -415,7 +415,7 @@ fn parseInt(comptime T: type, str: []const u8) !T {
|
|||
|
||||
if (comptime std.math.maxInt(T) < 1024)
|
||||
return error.Overflow;
|
||||
var base: T = if (base1024) 1024 else 1000;
|
||||
const base: T = if (base1024) 1024 else 1000;
|
||||
multiplier = try std.math.powi(T, base, @as(T, @intCast(pow)));
|
||||
}
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ pub const ErrorCollection = struct {
|
|||
|
||||
/// Appends an error to the collection
|
||||
fn insert(self: *Self, err: Error) !void {
|
||||
var dupe = Error{
|
||||
const dupe = Error{
|
||||
.option = try self.arena.allocator().dupe(u8, err.option),
|
||||
.kind = switch (err.kind) {
|
||||
.invalid_value => |v| Error.Kind{
|
||||
|
|
2
demo.zig
2
demo.zig
|
@ -2,7 +2,7 @@ const std = @import("std");
|
|||
const argsParser = @import("args");
|
||||
|
||||
pub fn main() !u8 {
|
||||
var argsAllocator = std.heap.page_allocator;
|
||||
const argsAllocator = std.heap.page_allocator;
|
||||
|
||||
const Options = struct {
|
||||
// This declares long options for double hyphen
|
||||
|
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
|||
const argsParser = @import("args");
|
||||
|
||||
pub fn main() !u8 {
|
||||
var argsAllocator = std.heap.page_allocator;
|
||||
const argsAllocator = std.heap.page_allocator;
|
||||
|
||||
const options = argsParser.parseWithVerbForCurrentProcess(
|
||||
struct {
|
||||
|
|
Loading…
Reference in New Issue
Block a user