Skip to content

Commit 393f478

Browse files
Goldziherclaude
andcommitted
fix(sysres): use then_some for the Windows memory counters
`bool::then` with a closure that only reads a field is what clippy's `unnecessary_lazy_evaluations` rejects, and it failed the Windows leg -- the one matrix combination (`comms shells` on windows-latest) that neither the macOS nor the Linux legs compile. Both call sites are eager field reads with no side effects, so `then_some` is identical in behaviour. Verified by cross-compiling rather than by inference: `cargo clippy --target x86_64-pc-windows-gnu --workspace --all-targets --tests --features "comms shells" -- -D warnings` now exits 0. That is not CI's MSVC toolchain, but it compiles the same `#[cfg(windows)]` paths that were failing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XWgvgjgdoPq3TjCxPyfbws
1 parent 23eedc3 commit 393f478

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/sysres.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ fn windows_working_set() -> Option<u64> {
460460
// its own size, as the API requires; `GetCurrentProcess` returns a pseudo-handle that
461461
// needs no closing.
462462
let ok = unsafe { K32GetProcessMemoryInfo(GetCurrentProcess(), &mut counters, counters.cb) };
463-
(ok != 0).then(|| counters.working_set_size as u64)
463+
(ok != 0).then_some(counters.working_set_size as u64)
464464
}
465465

466466
#[cfg(windows)]
@@ -552,7 +552,7 @@ fn peak_rss() -> Option<u64> {
552552
};
553553
// SAFETY: see `windows_working_set`.
554554
let ok = unsafe { K32GetProcessMemoryInfo(GetCurrentProcess(), &mut counters, counters.cb) };
555-
(ok != 0).then(|| counters.peak_working_set_size as u64)
555+
(ok != 0).then_some(counters.peak_working_set_size as u64)
556556
}
557557

558558
#[cfg(not(any(unix, windows)))]

0 commit comments

Comments
 (0)