Skip to content

Commit

Permalink
&Option<T> -> Option<&T> (helix-editor#11091)
Browse files Browse the repository at this point in the history
* refactor `starting_request_args` to only `ref` non-`Copy`

* refactor `needs_recompile` to only `ref` non-`Copy`

* refactor `add_workspace_folder` to only `ref` `Some`

---------

Co-authored-by: Rudxain <[email protected]>
  • Loading branch information
2 people authored and mxxntype committed Aug 14, 2024
1 parent dd9b945 commit b41ee02
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions helix-dap/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ impl Client {
)
}

pub fn starting_request_args(&self) -> &Option<Value> {
&self.starting_request_args
pub fn starting_request_args(&self) -> Option<&Value> {
self.starting_request_args.as_ref()
}

pub async fn tcp_process(
Expand Down
4 changes: 2 additions & 2 deletions helix-loader/src/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ fn build_tree_sitter_library(
}
}

let recompile = needs_recompile(&library_path, &parser_path, &scanner_path)
let recompile = needs_recompile(&library_path, &parser_path, scanner_path.as_ref())
.context("Failed to compare source and binary timestamps")?;

if !recompile {
Expand Down Expand Up @@ -568,7 +568,7 @@ fn build_tree_sitter_library(
fn needs_recompile(
lib_path: &Path,
parser_c_path: &Path,
scanner_path: &Option<PathBuf>,
scanner_path: Option<&PathBuf>,
) -> Result<bool> {
if !lib_path.exists() {
return Ok(true);
Expand Down
11 changes: 7 additions & 4 deletions helix-lsp/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl Client {
{
client.add_workspace_folder(
root_uri,
&workspace_folders_caps.change_notifications,
workspace_folders_caps.change_notifications.as_ref(),
);
}
});
Expand All @@ -136,7 +136,10 @@ impl Client {
.and_then(|cap| cap.workspace_folders.as_ref())
.filter(|cap| cap.supported.unwrap_or(false))
{
self.add_workspace_folder(root_uri, &workspace_folders_caps.change_notifications);
self.add_workspace_folder(
root_uri,
workspace_folders_caps.change_notifications.as_ref(),
);
true
} else {
// the server doesn't support multi workspaces, we need a new client
Expand All @@ -147,7 +150,7 @@ impl Client {
fn add_workspace_folder(
&self,
root_uri: Option<lsp::Url>,
change_notifications: &Option<OneOf<bool, String>>,
change_notifications: Option<&OneOf<bool, String>>,
) {
// root_uri is None just means that there isn't really any LSP workspace
// associated with this file. For servers that support multiple workspaces
Expand All @@ -162,7 +165,7 @@ impl Client {
self.workspace_folders
.lock()
.push(workspace_for_uri(root_uri.clone()));
if &Some(OneOf::Left(false)) == change_notifications {
if Some(&OneOf::Left(false)) == change_notifications {
// server specifically opted out of DidWorkspaceChange notifications
// let's assume the server will request the workspace folders itself
// and that we can therefore reuse the client (but are done now)
Expand Down

0 comments on commit b41ee02

Please sign in to comment.