From ad36882e0fbce83488b22343051f35f9b30ff847 Mon Sep 17 00:00:00 2001 From: "xiarui.xr" Date: Sat, 7 Oct 2023 15:03:01 +0800 Subject: [PATCH] minor fix: use if-else instead of match statement Signed-off-by: xiarui.xr --- kclvm/tools/src/LSP/src/util.rs | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/kclvm/tools/src/LSP/src/util.rs b/kclvm/tools/src/LSP/src/util.rs index 53ab11618..6976d9d9e 100644 --- a/kclvm/tools/src/LSP/src/util.rs +++ b/kclvm/tools/src/LSP/src/util.rs @@ -817,25 +817,22 @@ fn line_to_words(text: String) -> HashMap> { if is_id_start && !prev_word { start_pos = i; } - match is_id_continue { - true => { - // Continue searching for the end position. - if start_pos != usize::MAX { - continue_pos = i; - } + if is_id_continue { + // Continue searching for the end position. + if start_pos != usize::MAX { + continue_pos = i; } - false => { - // Find out the end position. - if continue_pos + 1 == i { - words.push(Word::new( - start_pos as u32, - i as u32, - chars[start_pos..i].iter().collect::().clone(), - )); - } - // Reset the start position. - start_pos = usize::MAX; + } else { + // Find out the end position. + if continue_pos + 1 == i { + words.push(Word::new( + start_pos as u32, + i as u32, + chars[start_pos..i].iter().collect::().clone(), + )); } + // Reset the start position. + start_pos = usize::MAX; } prev_word = is_id_continue; }