From 24f03097e3b4aef62aa56bb27e0853b60a4cb417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Mon, 27 Jun 2022 17:27:44 +0900 Subject: [PATCH] Remove some more unwraps --- helix-lsp/src/client.rs | 6 +++--- helix-lsp/src/jsonrpc.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 8ee9c9d71..cf6706b58 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -271,8 +271,8 @@ impl Client { // ------------------------------------------------------------------------------------------- pub(crate) async fn initialize(&self) -> Result { - if self.config.is_some() { - log::info!("Using custom LSP config: {}", self.config.as_ref().unwrap()); + if let Some(config) = &self.config { + log::info!("Using custom LSP config: {}", config); } #[allow(deprecated)] @@ -896,8 +896,8 @@ impl Client { Some(lsp::OneOf::Left(true)) | Some(lsp::OneOf::Right(_)) => (), // None | Some(false) _ => { + log::warn!("rename_symbol failed: The server does not support rename"); let err = "The server does not support rename"; - log::warn!("rename_symbol failed: {}", err); return Err(anyhow!(err)); } }; diff --git a/helix-lsp/src/jsonrpc.rs b/helix-lsp/src/jsonrpc.rs index b9b3fd2c0..ed63da137 100644 --- a/helix-lsp/src/jsonrpc.rs +++ b/helix-lsp/src/jsonrpc.rs @@ -310,7 +310,7 @@ fn method_call_serialize() { id: Id::Num(1), }; - let serialized = serde_json::to_string(&m).unwrap(); + let serialized = serde_json::json!(&m); assert_eq!( serialized, r#"{"jsonrpc":"2.0","method":"update","params":[1,2],"id":1}"# @@ -327,7 +327,7 @@ fn notification_serialize() { params: Params::Array(vec![Value::from(1), Value::from(2)]), }; - let serialized = serde_json::to_string(&n).unwrap(); + let serialized = serde_json::json!(&n); assert_eq!( serialized, r#"{"jsonrpc":"2.0","method":"update","params":[1,2]}"#