mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 23:04:26 +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!(
|
||||||
kind: TokenKind::Word,
|
matching_words.matching_bytes(&Token {
|
||||||
word: Cow::Borrowed("word"),
|
kind: TokenKind::Word,
|
||||||
byte_start: 0,
|
word: Cow::Borrowed("word"),
|
||||||
char_index: 0,
|
byte_start: 0,
|
||||||
byte_end: "word".len(),
|
char_index: 0,
|
||||||
char_map: None,
|
byte_end: "word".len(),
|
||||||
}), Some(3));
|
char_map: None,
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
}),
|
||||||
kind: TokenKind::Word,
|
Some(3)
|
||||||
word: Cow::Borrowed("nyc"),
|
);
|
||||||
byte_start: 0,
|
assert_eq!(
|
||||||
char_index: 0,
|
matching_words.matching_bytes(&Token {
|
||||||
byte_end: "nyc".len(),
|
kind: TokenKind::Word,
|
||||||
char_map: None,
|
word: Cow::Borrowed("nyc"),
|
||||||
}), None);
|
byte_start: 0,
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
char_index: 0,
|
||||||
kind: TokenKind::Word,
|
byte_end: "nyc".len(),
|
||||||
word: Cow::Borrowed("world"),
|
char_map: None,
|
||||||
byte_start: 0,
|
}),
|
||||||
char_index: 0,
|
None
|
||||||
byte_end: "world".len(),
|
);
|
||||||
char_map: None,
|
assert_eq!(
|
||||||
}), Some(5));
|
matching_words.matching_bytes(&Token {
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
kind: TokenKind::Word,
|
||||||
kind: TokenKind::Word,
|
word: Cow::Borrowed("world"),
|
||||||
word: Cow::Borrowed("splitted"),
|
byte_start: 0,
|
||||||
byte_start: 0,
|
char_index: 0,
|
||||||
char_index: 0,
|
byte_end: "world".len(),
|
||||||
byte_end: "splitted".len(),
|
char_map: None,
|
||||||
char_map: None,
|
}),
|
||||||
}), Some(5));
|
Some(5)
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
);
|
||||||
kind: TokenKind::Word,
|
assert_eq!(
|
||||||
word: Cow::Borrowed("thisnew"),
|
matching_words.matching_bytes(&Token {
|
||||||
byte_start: 0,
|
kind: TokenKind::Word,
|
||||||
char_index: 0,
|
word: Cow::Borrowed("splitted"),
|
||||||
byte_end: "thisnew".len(),
|
byte_start: 0,
|
||||||
char_map: None,
|
char_index: 0,
|
||||||
}), None);
|
byte_end: "splitted".len(),
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
char_map: None,
|
||||||
kind: TokenKind::Word,
|
}),
|
||||||
word: Cow::Borrowed("borld"),
|
Some(5)
|
||||||
byte_start: 0,
|
);
|
||||||
char_index: 0,
|
assert_eq!(
|
||||||
byte_end: "borld".len(),
|
matching_words.matching_bytes(&Token {
|
||||||
char_map: None,
|
kind: TokenKind::Word,
|
||||||
}), Some(5));
|
word: Cow::Borrowed("thisnew"),
|
||||||
assert_eq!(matching_words.matching_bytes(&Token{
|
byte_start: 0,
|
||||||
kind: TokenKind::Word,
|
char_index: 0,
|
||||||
word: Cow::Borrowed("wordsplit"),
|
byte_end: "thisnew".len(),
|
||||||
byte_start: 0,
|
char_map: None,
|
||||||
char_index: 0,
|
}),
|
||||||
byte_end: "wordsplit".len(),
|
None
|
||||||
char_map: None,
|
);
|
||||||
}), Some(4));
|
assert_eq!(
|
||||||
|
matching_words.matching_bytes(&Token {
|
||||||
|
kind: TokenKind::Word,
|
||||||
|
word: Cow::Borrowed("borld"),
|
||||||
|
byte_start: 0,
|
||||||
|
char_index: 0,
|
||||||
|
byte_end: "borld".len(),
|
||||||
|
char_map: None,
|
||||||
|
}),
|
||||||
|
Some(5)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
matching_words.matching_bytes(&Token {
|
||||||
|
kind: TokenKind::Word,
|
||||||
|
word: Cow::Borrowed("wordsplit"),
|
||||||
|
byte_start: 0,
|
||||||
|
char_index: 0,
|
||||||
|
byte_end: "wordsplit".len(),
|
||||||
|
char_map: None,
|
||||||
|
}),
|
||||||
|
Some(4)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user