Skip to content

Commit

Permalink
Update src/utils.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Arpad Borsos <swatinem@swatinem.de>
  • Loading branch information
jridgewell and Swatinem authored Nov 3, 2022
1 parent a8dbb2e commit 48bc965
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,8 @@ pub fn greatest_lower_bound<'a, T, K: Ord, F: Fn(&'a T) -> K>(
map: F,
) -> Option<&'a T> {
match slice.binary_search_by_key(key, map) {
Ok(index) => Some(&slice[index]),
Err(index) => {
if index > 0 {
Some(&slice[index - 1])
} else {
None
}
}
Ok(index) => slice.get(index),
Err(index) => slice.get(index.checked_sub(1)?),
}
}

Expand Down

0 comments on commit 48bc965

Please sign in to comment.