From 8e4240ed3786fd7b639af052b6860425216a42b0 Mon Sep 17 00:00:00 2001 From: Erasin Date: Wed, 20 Jul 2022 22:47:03 +0800 Subject: [PATCH] use as_ref convert NumberOrString --- helix-core/src/diagnostic.rs | 2 +- helix-lsp/src/lib.rs | 6 +++--- helix-term/src/application.rs | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/helix-core/src/diagnostic.rs b/helix-core/src/diagnostic.rs index 48a68dc02d2dd..41ee66c56a103 100644 --- a/helix-core/src/diagnostic.rs +++ b/helix-core/src/diagnostic.rs @@ -23,7 +23,7 @@ pub struct Range { pub end: usize, } -#[derive(Debug, Eq, Hash, PartialEq, Clone, Deserialize, Serialize)] +#[derive(Debug, Eq, Hash, PartialEq, Clone)] pub enum NumberOrString { Number(i32), String(String), diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index b6e364239ff1d..7cf9af5bcce5c 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -78,10 +78,10 @@ pub mod util { Error => lsp::DiagnosticSeverity::ERROR, }); - let code = match diag.code.clone() { + let code = match diag.code.as_ref() { Some(x) => match x { - NumberOrString::Number(x) => Some(lsp::NumberOrString::Number(x)), - NumberOrString::String(x) => Some(lsp::NumberOrString::String(x)), + NumberOrString::Number(n) => Some(lsp::NumberOrString::Number(*n)), + NumberOrString::String(s) => Some(lsp::NumberOrString::String(s.to_string())), }, None => None, }; diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 737b1cadf029b..2f22f0f9717b9 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -557,13 +557,13 @@ impl Application { } }; - let code = match diagnostic.code.clone() { + let code = match diagnostic.code.as_ref() { Some(x) => match x { - lsp::NumberOrString::Number(x) => { - Some(NumberOrString::Number(x)) + lsp::NumberOrString::Number(n) => { + Some(NumberOrString::Number(*n)) } - lsp::NumberOrString::String(x) => { - Some(NumberOrString::String(x)) + lsp::NumberOrString::String(s) => { + Some(NumberOrString::String(s.to_string())) } }, None => None,