This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
src/tools/rust-analyzer/crates/ide-completion/src Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -252,14 +252,16 @@ impl CompletionRelevance {
252252 /// Provides a relevance score. Higher values are more relevant.
253253 ///
254254 /// The absolute value of the relevance score is not meaningful, for
255- /// example a value of (!(0 as u32) / 2) doesn't mean "not relevant", rather
255+ /// example a value of BASE_SCORE doesn't mean "not relevant", rather
256256 /// it means "least relevant". The score value should only be used
257257 /// for relative ordering.
258258 ///
259259 /// See is_relevant if you need to make some judgement about score
260260 /// in an absolute sense.
261+ const BASE_SCORE : u32 = u32:: MAX / 2 ;
262+
261263 pub fn score ( self ) -> u32 {
262- let mut score = ! ( 0 as u32 ) / 2 ;
264+ let mut score = Self :: BASE_SCORE ;
263265 let CompletionRelevance {
264266 exact_name_match,
265267 type_match,
@@ -350,7 +352,7 @@ impl CompletionRelevance {
350352 /// some threshold such that we think it is especially likely
351353 /// to be relevant.
352354 pub fn is_relevant ( & self ) -> bool {
353- self . score ( ) > ! ( 0 as u32 ) / 2
355+ self . score ( ) > Self :: BASE_SCORE
354356 }
355357}
356358
You can’t perform that action at this time.
0 commit comments