fix some clippy warnings
This commit is contained in:
parent
cda3ff46f2
commit
8203a84c58
2 changed files with 4 additions and 10 deletions
|
|
@ -128,7 +128,7 @@ impl Scanner {
|
|||
input: ChangedContent,
|
||||
) -> Vec<CandidateWithPosition> {
|
||||
let content = input.content.unwrap_or_else(|| {
|
||||
std::fs::read_to_string(&input.file.unwrap()).expect("Failed to read file")
|
||||
std::fs::read_to_string(input.file.unwrap()).expect("Failed to read file")
|
||||
});
|
||||
|
||||
let input = ChangedContent {
|
||||
|
|
|
|||
|
|
@ -31,20 +31,18 @@ impl<'a> IndexConverter<'a> {
|
|||
// will only ever be incremented up to the length of the input string.
|
||||
//
|
||||
// This eliminates a "potential" panic that cannot actually happen
|
||||
let slice = unsafe {
|
||||
self.input.get_unchecked(self.curr_utf8..)
|
||||
};
|
||||
let slice = unsafe { self.input.get_unchecked(self.curr_utf8..) };
|
||||
|
||||
for c in slice.chars() {
|
||||
if self.curr_utf8 >= pos {
|
||||
break
|
||||
break;
|
||||
}
|
||||
|
||||
self.curr_utf8 += c.len_utf8();
|
||||
self.curr_utf16 += c.len_utf16();
|
||||
}
|
||||
|
||||
return self.curr_utf16 as i64;
|
||||
self.curr_utf16 as i64
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -66,19 +64,16 @@ mod test {
|
|||
(4, 4),
|
||||
(5, 5),
|
||||
(6, 6),
|
||||
|
||||
// inside the 🔥
|
||||
(7, 8),
|
||||
(8, 8),
|
||||
(9, 8),
|
||||
(10, 8),
|
||||
|
||||
// inside the 🥳
|
||||
(11, 10),
|
||||
(12, 10),
|
||||
(13, 10),
|
||||
(14, 10),
|
||||
|
||||
// <space>world!
|
||||
(15, 11),
|
||||
(16, 12),
|
||||
|
|
@ -87,7 +82,6 @@ mod test {
|
|||
(19, 15),
|
||||
(20, 16),
|
||||
(21, 17),
|
||||
|
||||
// Past the end should return the last utf-16 character index
|
||||
(22, 17),
|
||||
(100, 17),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue