Minor stylistic fixes.
This commit is contained in:
parent
4299b43859
commit
1328e59fc7
22
src/map.rs
22
src/map.rs
|
@ -139,15 +139,16 @@ fn binary_search_by_key_range<'a, K, V, Q: 'a, R>(slice: &[Option<(K, V)>], rang
|
|||
// any of these guarantees.
|
||||
|
||||
// Find the beginning
|
||||
let begin = if let Bound::Unbounded = range.start() {
|
||||
0
|
||||
let begin;
|
||||
if let Bound::Unbounded = range.start() {
|
||||
begin = 0;
|
||||
} else {
|
||||
macro_rules! is_before_range {
|
||||
( $item: expr) => {
|
||||
match &range.start() {
|
||||
Bound::Included(ref key_begin) => $item < Some(key_begin.borrow()),
|
||||
Bound::Excluded(ref key_begin) => $item <= Some(key_begin.borrow()),
|
||||
Bound::Unbounded => unreachable!(),
|
||||
Bound::Unbounded => unreachable!()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -159,25 +160,26 @@ fn binary_search_by_key_range<'a, K, V, Q: 'a, R>(slice: &[Option<(K, V)>], rang
|
|||
right = middle - 1;
|
||||
} else {
|
||||
left = middle;
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
if left == slice.len() || is_before_range!(key!(slice[left])) {
|
||||
return Err(())
|
||||
}
|
||||
left
|
||||
begin = left
|
||||
};
|
||||
|
||||
// Find the ending
|
||||
let end = if let Bound::Unbounded = range.end() {
|
||||
slice.len()
|
||||
let end;
|
||||
if let Bound::Unbounded = range.end() {
|
||||
end = slice.len()
|
||||
} else {
|
||||
macro_rules! is_after_range {
|
||||
( $item:expr ) => {
|
||||
match &range.end() {
|
||||
Bound::Included(ref key_end) => $item > Some(key_end.borrow()),
|
||||
Bound::Excluded(ref key_end) => $item >= Some(key_end.borrow()),
|
||||
Bound::Unbounded => unreachable!(),
|
||||
Bound::Unbounded => unreachable!()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -190,13 +192,13 @@ fn binary_search_by_key_range<'a, K, V, Q: 'a, R>(slice: &[Option<(K, V)>], rang
|
|||
left = middle + 1;
|
||||
} else {
|
||||
right = middle;
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
if right == 0 || is_after_range!(key!(slice[right - 1])) {
|
||||
return Err(())
|
||||
}
|
||||
right
|
||||
end = right
|
||||
};
|
||||
|
||||
Ok((begin, end))
|
||||
|
|
Loading…
Reference in New Issue