Binary search to find the nearest item at or before the given offset. Returns the index of the item whose `start` position is closest to (but not exceeding) the given offset.
(measurements: &[VirtualItem], offset: u32)
| 9 | /// Returns the index of the item whose `start` position is closest to |
| 10 | /// (but not exceeding) the given offset. |
| 11 | pub(crate) fn find_nearest_binary_search(measurements: &[VirtualItem], offset: u32) -> usize { |
| 12 | measurements |
| 13 | .binary_search_by(|item| item.start().cmp(&offset)) |
| 14 | .unwrap_or_else(|idx| idx.saturating_sub(1)) |
| 15 | } |
| 16 | |
| 17 | /// Extract indices from a range with overscan applied. |
| 18 | pub(crate) fn default_range_extractor( |
no test coverage detected