mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Improve readability be replacing hard-to-read if-else branches with a match
This commit is contained in:
parent
a8a606cdc4
commit
0d87eee3a9
1 changed files with 20 additions and 16 deletions
|
@ -372,7 +372,8 @@ impl HighlightedRangeStack {
|
|||
} else {
|
||||
let maybe_idx =
|
||||
prev.iter().position(|parent| parent.range.contains(child.range.start()));
|
||||
if let (Some(_), Some(idx)) = (overwrite_parent, maybe_idx) {
|
||||
match (overwrite_parent, maybe_idx) {
|
||||
(Some(_), Some(idx)) => {
|
||||
Self::intersect_partial(&mut prev[idx], &child);
|
||||
let insert_idx = if prev[idx].range.is_empty() {
|
||||
prev.remove(idx);
|
||||
|
@ -381,17 +382,20 @@ impl HighlightedRangeStack {
|
|||
idx + 1
|
||||
};
|
||||
prev.insert(insert_idx, child);
|
||||
} else if let None = maybe_idx {
|
||||
}
|
||||
(_, None) => {
|
||||
let idx = prev
|
||||
.binary_search_by_key(&child.range.start(), |range| range.range.start())
|
||||
.unwrap_or_else(|x| x);
|
||||
prev.insert(idx, child);
|
||||
} else {
|
||||
}
|
||||
_ => {
|
||||
unreachable!("child range should be completely contained in parent range");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn add(&mut self, range: HighlightedRange) {
|
||||
self.stack
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue