mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:24:49 +01:00
all: prefer else => |e| return e, over else => return err,
When switching on an error, using the captured value instead of the original one is always preferable since its error set has been narrowed to only contain errors which haven't already been handled by other switch prongs. The subsequent commits will disallow this form as an unreachable `else` prong.
This commit is contained in:
parent
9e949f95c1
commit
6e35138901
2 changed files with 3 additions and 3 deletions
|
|
@ -114,7 +114,7 @@ fn writeHeader(
|
|||
if (typeflag == .symbolic_link)
|
||||
header.setLinkname(link_name) catch |err| switch (err) {
|
||||
error.NameTooLong => try w.writeExtendedHeader(.gnu_long_link, &.{link_name}),
|
||||
else => return err,
|
||||
else => |e| return e,
|
||||
};
|
||||
try header.write(w.underlying_writer);
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ fn setPath(w: *Writer, header: *Header, sub_path: []const u8) Error!void {
|
|||
&.{ w.prefix, "/", sub_path };
|
||||
try w.writeExtendedHeader(.gnu_long_name, buffers);
|
||||
},
|
||||
else => return err,
|
||||
else => |e| return e,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1187,7 +1187,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime
|
|||
return error.MemoryLeakDetected;
|
||||
}
|
||||
},
|
||||
else => return err,
|
||||
else => |e| return e,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue