Consistently use wrapping add to avoid overflow in debug when query starts with a separator

This commit is contained in:
Louis Dureuil 2023-05-29 10:08:27 +02:00
parent 087866d59f
commit 73198179f1
No known key found for this signature in database

View File

@ -77,13 +77,9 @@ pub fn located_query_terms_from_tokens(
}
}
TokenKind::Separator(separator_kind) => {
match separator_kind {
SeparatorKind::Hard => {
position += 1;
}
SeparatorKind::Soft => {
position += 0;
}
// add penalty for hard separators
if let SeparatorKind::Hard = separator_kind {
position = position.wrapping_add(1);
}
phrase = 'phrase: {