Merge pull request #56 from 9hvn9yt2vk-netizen/find-input-underflow

shader: look up an input channel without underflowing
This commit is contained in:
Marvis authored and GitHub committed 2026-11-24 01:34:59 +01:00
commit 0d7b42a3a9
2 files changed
+58 -1

No files matched your search

+3 -1
View File
@@ -1018,8 +1018,10 @@ impl<'a> Lower<'a> {
fn find_input(&self, row: u8, channel: u8) -> Option<(usize, u8)> {
self.s.inputs.iter().enumerate().find_map(|(id, e)| {
let r = e.row?;
// `then`, not `then_some`: the channel is only past `col` when
// the condition holds.
(r == u32::from(row) && channel >= e.col && channel < e.col + e.cols)
.then_some((id, channel - e.col))
.then(|| (id, channel - e.col))
})
}