diff --git a/crates/victory-gpu/src/book.rs b/crates/victory-gpu/src/book.rs index 87de67d..b8b8b4e 100644 --- a/crates/victory-gpu/src/book.rs +++ b/crates/victory-gpu/src/book.rs @@ -146,7 +146,9 @@ impl Book { /// The live entry that starts last at or below `at`, and the next above. fn neighbours(&self, at: u64) -> [Option<&Entry>; 2] { let below = self.by_start.range(..=(at, u64::MAX)).next_back(); - let above = self.by_start.range((at + 1, 0)..).next(); + // Saturating, as the lower bounds above: `at` is an address the + // card reported, any u64. + let above = self.by_start.range((at.saturating_add(1), 0)..).next(); [below, above].map(|e| e.and_then(|((_, id), ())| self.live.get(id))) } @@ -748,5 +750,7 @@ mod tests { assert_eq!(b.neighbours(0x1000_0100)[1].map(|e| e.what.as_str()), Some("two")); b.remove(two, 3, 13); assert!(b.neighbours(u64::MAX - 1)[0].is_none() && b.by_object.is_empty()); + // An address the card reports can be anything, the top one included. + assert!(b.neighbours(u64::MAX)[0].is_none() && b.neighbours(u64::MAX)[1].is_none()); } }