on master help sign in
Remove some more unwraps
commit24f03097e3b4aef62aa56bb27e0853b60a4cb417 authorBlaž Hrastnik <blaz@mxxn.io> dateMon 27 Jun 2022, 17:27 (4 years ago) parent33d287a
2 files changed+5−5
helix-lsp/src/client.rs+3−3 helix-lsp/src/jsonrpc.rs+2−2
helix-lsp/src/client.rs+3−3
@@ -271,8 +271,8 @@ impl Client {
271271 // -------------------------------------------------------------------------------------------
272272
273273 pub(crate) async fn initialize(&self) -> Result<lsp::InitializeResult> {
274− if self.config.is_some() {
275− log::info!("Using custom LSP config: {}", self.config.as_ref().unwrap());
274+ if let Some(config) = &self.config {
275+ log::info!("Using custom LSP config: {}", config);
276276 }
277277
278278 #[allow(deprecated)]
@@ -896,8 +896,8 @@ impl Client {
896896 Some(lsp::OneOf::Left(true)) | Some(lsp::OneOf::Right(_)) => (),
897897 // None | Some(false)
898898 _ => {
899+ log::warn!("rename_symbol failed: The server does not support rename");
899900 let err = "The server does not support rename";
900− log::warn!("rename_symbol failed: {}", err);
901901 return Err(anyhow!(err));
902902 }
903903 };
helix-lsp/src/jsonrpc.rs+2−2
@@ -310,7 +310,7 @@ fn method_call_serialize() {
310310 id: Id::Num(1),
311311 };
312312
313− let serialized = serde_json::to_string(&m).unwrap();
313+ let serialized = serde_json::json!(&m);
314314 assert_eq!(
315315 serialized,
316316 r#"{"jsonrpc":"2.0","method":"update","params":[1,2],"id":1}"#
@@ -327,7 +327,7 @@ fn notification_serialize() {
327327 params: Params::Array(vec![Value::from(1), Value::from(2)]),
328328 };
329329
330− let serialized = serde_json::to_string(&n).unwrap();
330+ let serialized = serde_json::json!(&n);
331331 assert_eq!(
332332 serialized,
333333 r#"{"jsonrpc":"2.0","method":"update","params":[1,2]}"#