Fix clippy broken code

This commit is contained in:
Andras Schmelczer 2024-12-19 22:00:51 +00:00
parent b243a376e7
commit 26cce993f5
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
2 changed files with 6 additions and 13 deletions

View file

@ -145,6 +145,7 @@ mod test {
); );
} }
#[ignore = "it's too slow"]
#[test_matrix( [ #[test_matrix( [
"pride_and_prejudice.txt", "pride_and_prejudice.txt",
"romeo_and_juliet.txt", "romeo_and_juliet.txt",

View file

@ -97,10 +97,7 @@ where
match self { match self {
Operation::Insert { text, .. } => builder.insert( Operation::Insert { text, .. } => builder.insert(
self.start_index(), self.start_index(),
&text &text.iter().map(Token::original).collect::<String>(),
.iter()
.map(super::super::tokenizer::token::Token::original)
.collect::<String>(),
), ),
Operation::Delete { Operation::Delete {
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
@ -140,16 +137,13 @@ where
} }
/// Returns the range of indices of characters that the operation affects. /// Returns the range of indices of characters that the operation affects.
pub fn range(&self) -> Range<usize> { self.start_index()..self.end_index() - 1 } pub fn range(&self) -> Range<usize> { self.start_index()..self.end_index() + 1 }
/// Returns the number of affected characters. It is always greater than 0 /// Returns the number of affected characters. It is always greater than 0
/// because empty operations cannot be created. /// because empty operations cannot be created.
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
match self { match self {
Operation::Insert { text, .. } => text Operation::Insert { text, .. } => text.iter().map(Token::get_original_length).sum(),
.iter()
.map(super::super::tokenizer::token::Token::get_original_length)
.sum(),
Operation::Delete { Operation::Delete {
deleted_character_count, deleted_character_count,
.. ..
@ -223,7 +217,7 @@ where
let trimmed_length = previous_inserted_text let trimmed_length = previous_inserted_text
.iter() .iter()
.skip(offset_in_tokens) .skip(offset_in_tokens)
.map(super::super::tokenizer::token::Token::get_original_length) .map(Token::get_original_length)
.sum::<usize>(); .sum::<usize>();
let trimmed_operation = let trimmed_operation =
Operation::create_insert(index, text[trimmed_length_in_tokens..].to_vec()); Operation::create_insert(index, text[trimmed_length_in_tokens..].to_vec());
@ -311,9 +305,7 @@ where
write!( write!(
f, f,
"<insert '{}' from index {}>", "<insert '{}' from index {}>",
text.iter() text.iter().map(Token::original).collect::<String>(),
.map(super::super::tokenizer::token::Token::original)
.collect::<String>(),
index index
) )
} }