aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-06-24 00:35:09 +0100
committerPaul Daniel Faria <[email protected]>2020-06-24 00:35:09 +0100
commit0d87eee3a9d3950cd02a80bf3974b4b165c5a76c (patch)
tree2e7419bd9c19f489420b71e767741469390abb4c /crates/ra_ide
parenta8a606cdc4abc3e7f5938ffaf0128b0935b3ab8a (diff)
Improve readability be replacing hard-to-read if-else branches with a match
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs36
1 files changed, 20 insertions, 16 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 91f27aa2a..028b55902 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -372,22 +372,26 @@ impl HighlightedRangeStack {
372 } else { 372 } else {
373 let maybe_idx = 373 let maybe_idx =
374 prev.iter().position(|parent| parent.range.contains(child.range.start())); 374 prev.iter().position(|parent| parent.range.contains(child.range.start()));
375 if let (Some(_), Some(idx)) = (overwrite_parent, maybe_idx) { 375 match (overwrite_parent, maybe_idx) {
376 Self::intersect_partial(&mut prev[idx], &child); 376 (Some(_), Some(idx)) => {
377 let insert_idx = if prev[idx].range.is_empty() { 377 Self::intersect_partial(&mut prev[idx], &child);
378 prev.remove(idx); 378 let insert_idx = if prev[idx].range.is_empty() {
379 idx 379 prev.remove(idx);
380 } else { 380 idx
381 idx + 1 381 } else {
382 }; 382 idx + 1
383 prev.insert(insert_idx, child); 383 };
384 } else if let None = maybe_idx { 384 prev.insert(insert_idx, child);
385 let idx = prev 385 }
386 .binary_search_by_key(&child.range.start(), |range| range.range.start()) 386 (_, None) => {
387 .unwrap_or_else(|x| x); 387 let idx = prev
388 prev.insert(idx, child); 388 .binary_search_by_key(&child.range.start(), |range| range.range.start())
389 } else { 389 .unwrap_or_else(|x| x);
390 unreachable!("child range should be completely contained in parent range"); 390 prev.insert(idx, child);
391 }
392 _ => {
393 unreachable!("child range should be completely contained in parent range");
394 }
391 } 395 }
392 } 396 }
393 } 397 }