mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-23 13:24:27 +01:00
Run cargo fmt on matching_words.rs
This commit is contained in:
parent
5ab505be33
commit
2d7607734e
@ -42,10 +42,7 @@ impl MatchingWords {
|
|||||||
let len = bytes_to_highlight(word_to_highlight.text(), query_word);
|
let len = bytes_to_highlight(word_to_highlight.text(), query_word);
|
||||||
Some(word_to_highlight.num_chars_from_bytes(len))
|
Some(word_to_highlight.num_chars_from_bytes(len))
|
||||||
} else {
|
} else {
|
||||||
Some(
|
Some(word_to_highlight.num_chars_from_bytes(word_to_highlight.text().len()))
|
||||||
word_to_highlight
|
|
||||||
.num_chars_from_bytes(word_to_highlight.text().len()),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_otherwise => None,
|
_otherwise => None,
|
||||||
@ -276,61 +273,82 @@ mod tests {
|
|||||||
|
|
||||||
let matching_words = MatchingWords::from_query_tree(&query_tree);
|
let matching_words = MatchingWords::from_query_tree(&query_tree);
|
||||||
|
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
assert_eq!(
|
||||||
|
matching_words.matching_bytes(&Token {
|
||||||
kind: TokenKind::Word,
|
kind: TokenKind::Word,
|
||||||
word: Cow::Borrowed("word"),
|
word: Cow::Borrowed("word"),
|
||||||
byte_start: 0,
|
byte_start: 0,
|
||||||
char_index: 0,
|
char_index: 0,
|
||||||
byte_end: "word".len(),
|
byte_end: "word".len(),
|
||||||
char_map: None,
|
char_map: None,
|
||||||
}), Some(3));
|
}),
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
Some(3)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
matching_words.matching_bytes(&Token {
|
||||||
kind: TokenKind::Word,
|
kind: TokenKind::Word,
|
||||||
word: Cow::Borrowed("nyc"),
|
word: Cow::Borrowed("nyc"),
|
||||||
byte_start: 0,
|
byte_start: 0,
|
||||||
char_index: 0,
|
char_index: 0,
|
||||||
byte_end: "nyc".len(),
|
byte_end: "nyc".len(),
|
||||||
char_map: None,
|
char_map: None,
|
||||||
}), None);
|
}),
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
None
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
matching_words.matching_bytes(&Token {
|
||||||
kind: TokenKind::Word,
|
kind: TokenKind::Word,
|
||||||
word: Cow::Borrowed("world"),
|
word: Cow::Borrowed("world"),
|
||||||
byte_start: 0,
|
byte_start: 0,
|
||||||
char_index: 0,
|
char_index: 0,
|
||||||
byte_end: "world".len(),
|
byte_end: "world".len(),
|
||||||
char_map: None,
|
char_map: None,
|
||||||
}), Some(5));
|
}),
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
Some(5)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
matching_words.matching_bytes(&Token {
|
||||||
kind: TokenKind::Word,
|
kind: TokenKind::Word,
|
||||||
word: Cow::Borrowed("splitted"),
|
word: Cow::Borrowed("splitted"),
|
||||||
byte_start: 0,
|
byte_start: 0,
|
||||||
char_index: 0,
|
char_index: 0,
|
||||||
byte_end: "splitted".len(),
|
byte_end: "splitted".len(),
|
||||||
char_map: None,
|
char_map: None,
|
||||||
}), Some(5));
|
}),
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
Some(5)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
matching_words.matching_bytes(&Token {
|
||||||
kind: TokenKind::Word,
|
kind: TokenKind::Word,
|
||||||
word: Cow::Borrowed("thisnew"),
|
word: Cow::Borrowed("thisnew"),
|
||||||
byte_start: 0,
|
byte_start: 0,
|
||||||
char_index: 0,
|
char_index: 0,
|
||||||
byte_end: "thisnew".len(),
|
byte_end: "thisnew".len(),
|
||||||
char_map: None,
|
char_map: None,
|
||||||
}), None);
|
}),
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
None
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
matching_words.matching_bytes(&Token {
|
||||||
kind: TokenKind::Word,
|
kind: TokenKind::Word,
|
||||||
word: Cow::Borrowed("borld"),
|
word: Cow::Borrowed("borld"),
|
||||||
byte_start: 0,
|
byte_start: 0,
|
||||||
char_index: 0,
|
char_index: 0,
|
||||||
byte_end: "borld".len(),
|
byte_end: "borld".len(),
|
||||||
char_map: None,
|
char_map: None,
|
||||||
}), Some(5));
|
}),
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
Some(5)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
matching_words.matching_bytes(&Token {
|
||||||
kind: TokenKind::Word,
|
kind: TokenKind::Word,
|
||||||
word: Cow::Borrowed("wordsplit"),
|
word: Cow::Borrowed("wordsplit"),
|
||||||
byte_start: 0,
|
byte_start: 0,
|
||||||
char_index: 0,
|
char_index: 0,
|
||||||
byte_end: "wordsplit".len(),
|
byte_end: "wordsplit".len(),
|
||||||
char_map: None,
|
char_map: None,
|
||||||
}), Some(4));
|
}),
|
||||||
|
Some(4)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user