summaryrefslogtreecommitdiff
path: root/cli/lsp/tsc.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-03-15 17:46:36 -0400
committerGitHub <noreply@github.com>2023-03-15 17:46:36 -0400
commitfb021d7ceff3f8b1d7cdb0c2bdd75ea07c0428d2 (patch)
tree09cb2bf87bba760b1abf706e0b8faedc9c368bbc /cli/lsp/tsc.rs
parentca51f4f6c058d16ac438ad75ac92e8954895f5aa (diff)
refactor: remove usages of `map_or` / `map_or_else` (#18212)
These methods are confusing because the arguments are backwards. I feel like they should have never been added to `Option<T>` and that clippy should suggest rewriting to `map(...).unwrap_or(...)`/`map(...).unwrap_or_else(|| ...)` https://github.com/rust-lang/rfcs/issues/1025
Diffstat (limited to 'cli/lsp/tsc.rs')
-rw-r--r--cli/lsp/tsc.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index 79c1817e2..335d91ed7 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -1024,15 +1024,19 @@ impl NavigationTree {
) -> bool {
let mut should_include = self.should_include_entry();
if !should_include
- && self.child_items.as_ref().map_or(true, |v| v.is_empty())
+ && self
+ .child_items
+ .as_ref()
+ .map(|v| v.is_empty())
+ .unwrap_or(true)
{
return false;
}
let children = self
.child_items
- .as_ref()
- .map_or(&[] as &[NavigationTree], |v| v.as_slice());
+ .as_deref()
+ .unwrap_or(&[] as &[NavigationTree]);
for span in self.spans.iter() {
let range = TextRange::at(span.start.into(), span.length.into());
let mut symbol_children = Vec::<lsp::DocumentSymbol>::new();
@@ -1514,7 +1518,8 @@ impl RefactorActionInfo {
.iter()
.find(|action| action.matches(&self.name));
maybe_match
- .map_or(lsp::CodeActionKind::REFACTOR, |action| action.kind.clone())
+ .map(|action| action.kind.clone())
+ .unwrap_or(lsp::CodeActionKind::REFACTOR)
}
}