Skip to content

Commit

Permalink
use as_ref convert NumberOrString
Browse files Browse the repository at this point in the history
  • Loading branch information
erasin committed Jul 20, 2022
1 parent a127242 commit 8e4240e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion helix-core/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions helix-lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
10 changes: 5 additions & 5 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8e4240e

Please # to comment.