summaryrefslogtreecommitdiff
path: root/src/config.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 12:52:43 -0300
committerGabriel Schneider <[email protected]>2026-11-06 14:56:36 -0300
commitcf9e075d3537698e76a8fb22dc1a63622ca78c45 (patch)
tree30fd1c4964426f5083f8526a8d82147cc25686ec /src/config.zig
parent66f032821a0a7bebe08e852db170e0f282a02f48 (diff)
downloadpardes-cf9e075d3537698e76a8fb22dc1a63622ca78c45.tar.gz
pardes-cf9e075d3537698e76a8fb22dc1a63622ca78c45.zip
idioms #8, two more of each: config's switchedTo reads on or off through stringToEnum, and main's pager line, a working directory of 4096 into 4200, is catch unreachable where a lone newline stood for an overflow it cannot have
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/config.zig')
-rw-r--r--src/config.zig4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/config.zig b/src/config.zig
index c89ab2e6..98dd1ae3 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -1009,9 +1009,7 @@ pub const Runtime = struct {
fn switchedTo(argument: ?[]const u8) error{NotOnOrOff}!?bool {
const text = std.mem.trim(u8, argument orelse "", " \t\r\n");
if (text.len == 0) return null;
- if (std.mem.eql(u8, text, "on")) return true;
- if (std.mem.eql(u8, text, "off")) return false;
- return error.NotOnOrOff;
+ return (std.meta.stringToEnum(enum { on, off }, text) orelse return error.NotOnOrOff) == .on;
}
// Slices are borrowed for one writeReport call. A root ctl read