diff --git a/Cargo.toml b/Cargo.toml index 272e1bf..4adaf56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,12 +41,12 @@ lto = true opt-level = 3 strip="debuginfo" # Keep some info for better panics -[workspace.lints.rust] +[lints.rust] unsafe_code = "forbid" rust_2018_idioms = { level = "warn", priority = -1 } missing_debug_implementations = "warn" -[workspace.lints.clippy] +[lints.clippy] await_holding_lock = "warn" dbg_macro = "warn" empty_enum = "warn" diff --git a/src/operation_transformation/edited_text.rs b/src/operation_transformation/edited_text.rs index 3e37641..4e9c7be 100644 --- a/src/operation_transformation/edited_text.rs +++ b/src/operation_transformation/edited_text.rs @@ -137,7 +137,6 @@ where operation, Operation::Insert { .. } | Operation::Equal { .. } ); - println!("{side} {operation:?} ({maybe_left_op:?}, {maybe_right_op:?})"); let original_length = operation.len() as i64; let result = match side { @@ -152,7 +151,6 @@ where while let Some(cursor) = left_cursors.next_if(|cursor| { cursor.char_index <= seen_left_length + original_length as usize }) { - println!("cursor {}", cursor.char_index); merged_cursors.push( cursor.with_index((cursor.char_index as i64 + shift) as usize), ); @@ -179,8 +177,6 @@ where while let Some(cursor) = right_cursors.next_if(|cursor| { cursor.char_index <= seen_right_length + original_length as usize }) { - println!("cursor {}", cursor.char_index); - merged_cursors.push( cursor.with_index((cursor.char_index as i64 + shift) as usize), ); @@ -198,8 +194,6 @@ where } }; - println!(" = {result:?}"); - if result.len() == 0 { continue; } @@ -233,8 +227,6 @@ where #[cfg(test)] mod tests { - use std::env; - use insta::assert_debug_snapshot; use pretty_assertions::assert_eq; diff --git a/src/operation_transformation/operation.rs b/src/operation_transformation/operation.rs index 29fdeff..6efaa91 100644 --- a/src/operation_transformation/operation.rs +++ b/src/operation_transformation/operation.rs @@ -96,9 +96,9 @@ where fn order(&self) -> usize { match self { - Operation::Equal { order, .. } => *order, - Operation::Insert { order, .. } => *order, - Operation::Delete { order, .. } => *order, + Operation::Equal { order, .. } + | Operation::Insert { order, .. } + | Operation::Delete { order, .. } => *order, } } @@ -145,14 +145,14 @@ where .is_none_or(|text| builder.get_slice_from_remaining(self.len()) == *text), "Text (`{}`) which is supposed to be equal does not match the text in the \ range: `{}`", - text.as_ref().unwrap_or(&"".to_owned()), + text.as_ref().unwrap_or(&String::new()), builder.get_slice_from_remaining(self.len()) ); - builder.retain(*length) + builder.retain(*length); } Operation::Insert { text, .. } => { - builder.insert(&text.iter().map(Token::original).collect::()) + builder.insert(&text.iter().map(Token::original).collect::()); } Operation::Delete { #[cfg(debug_assertions)] @@ -166,11 +166,11 @@ where .as_ref() .is_none_or(|text| builder.get_slice_from_remaining(self.len()) == *text), "Text to-be-deleted `{}` does not match the text in the range: `{}`", - deleted_text.as_ref().unwrap_or(&"".to_owned()), + deleted_text.as_ref().unwrap_or(&String::new()), builder.get_slice_from_remaining(self.len()) ); - builder.delete(*deleted_character_count) + builder.delete(*deleted_character_count); } } diff --git a/src/utils/string_builder.rs b/src/utils/string_builder.rs index 5659d3e..af24d82 100644 --- a/src/utils/string_builder.rs +++ b/src/utils/string_builder.rs @@ -19,7 +19,7 @@ impl StringBuilder<'_> { buffer: String::with_capacity(original.len()), #[cfg(debug_assertions)] - remaining: original.to_string(), + remaining: original.to_owned(), } }