summaryrefslogtreecommitdiff
path: root/cli/lsp/documents.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/documents.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/documents.rs')
-rw-r--r--cli/lsp/documents.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs
index 9426378d5..9299c662c 100644
--- a/cli/lsp/documents.rs
+++ b/cli/lsp/documents.rs
@@ -490,7 +490,8 @@ impl Document {
pub fn script_version(&self) -> String {
self
.maybe_lsp_version()
- .map_or_else(|| self.fs_version().to_string(), |v| v.to_string())
+ .map(|v| v.to_string())
+ .unwrap_or_else(|| self.fs_version().to_string())
}
pub fn is_diagnosable(&self) -> bool {
@@ -901,15 +902,13 @@ impl Documents {
let mut file_system_docs = self.file_system_docs.lock();
file_system_docs.docs.remove(specifier)
})
- .map_or_else(
- || {
- Err(custom_error(
- "NotFound",
- format!("The specifier \"{specifier}\" was not found."),
- ))
- },
- Ok,
- )?;
+ .map(Ok)
+ .unwrap_or_else(|| {
+ Err(custom_error(
+ "NotFound",
+ format!("The specifier \"{specifier}\" was not found."),
+ ))
+ })?;
self.dirty = true;
let doc = doc.with_change(version, changes, self.get_resolver())?;
self.open_docs.insert(doc.specifier().clone(), doc.clone());