refactor: prefer orelse to if(pred) |x| x else y

This commit is contained in:
CJ van den Berg 2024-08-29 12:34:56 +02:00
parent 1caf2aa0f6
commit c01576412a
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
15 changed files with 43 additions and 43 deletions

View file

@ -44,7 +44,7 @@ pub fn write(self: *Self, bytes: []const u8) !usize {
}
pub fn input(self: *const Self, bytes: []const u8) !void {
const pid = if (self.pid) |pid| pid else return error.Closed;
const pid = self.pid orelse return error.Closed;
var remaining = bytes;
while (remaining.len > 0)
remaining = loop: {
@ -131,7 +131,7 @@ const Process = struct {
var bytes: []u8 = "";
if (try m.match(.{ "input", tp.extract(&bytes) })) {
const sp = if (self.sp) |sp| sp else return tp.exit_error(error.Closed, null);
const sp = self.sp orelse return tp.exit_error(error.Closed, null);
try sp.send(bytes);
} else if (try m.match(.{"close"})) {
try self.close();