diff options
Diffstat (limited to 'helix-core/src/transaction.rs')
-rw-r--r-- | helix-core/src/transaction.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs index 10219142..048839b3 100644 --- a/helix-core/src/transaction.rs +++ b/helix-core/src/transaction.rs @@ -1,5 +1,5 @@ -use crate::{Range, Rope, Selection, State, Tendril}; -use std::{borrow::Cow, convert::TryFrom}; +use crate::{Range, Rope, Selection, Tendril}; +use std::borrow::Cow; /// (from, to, replacement) pub type Change = (usize, usize, Option<Tendril>); @@ -163,7 +163,7 @@ impl ChangeSet { head_a = a; head_b = changes_b.next(); } - (None, val) | (val, None) => return unreachable!("({:?})", val), + (None, val) | (val, None) => unreachable!("({:?})", val), (Some(Retain(i)), Some(Retain(j))) => match i.cmp(&j) { Ordering::Less => { changes.retain(i); @@ -202,7 +202,7 @@ impl ChangeSet { } } } - (Some(Insert(mut s)), Some(Retain(j))) => { + (Some(Insert(s)), Some(Retain(j))) => { let len = s.chars().count(); match len.cmp(&j) { Ordering::Less => { @@ -274,7 +274,6 @@ impl ChangeSet { let mut changes = Self::with_capacity(self.changes.len()); let mut pos = 0; - let mut len = 0; for change in &self.changes { use Operation::*; @@ -581,6 +580,7 @@ impl<'a> Iterator for ChangeIterator<'a> { #[cfg(test)] mod test { use super::*; + use crate::State; #[test] fn composition() { @@ -699,7 +699,7 @@ mod test { #[test] fn changes_iter() { - let mut state = State::new("hello world!\ntest 123".into()); + let state = State::new("hello world!\ntest 123".into()); let changes = vec![(6, 11, Some("void".into())), (12, 17, None)]; let transaction = Transaction::change(&state.doc, changes.clone().into_iter()); assert_eq!(transaction.changes_iter().collect::<Vec<_>>(), changes); @@ -731,7 +731,7 @@ mod test { // retain 1, e // retain 2, l - let mut changes = t1 + let changes = t1 .changes .compose(t2.changes) .compose(t3.changes) @@ -746,7 +746,7 @@ mod test { #[test] fn combine_with_empty() { let empty = Rope::from(""); - let mut a = ChangeSet::new(&empty); + let a = ChangeSet::new(&empty); let mut b = ChangeSet::new(&empty); b.insert("a".into()); @@ -762,7 +762,7 @@ mod test { const TEST_CASE: &'static str = "Hello, これはヘリックスエディターです!"; let empty = Rope::from(""); - let mut a = ChangeSet::new(&empty); + let a = ChangeSet::new(&empty); let mut b = ChangeSet::new(&empty); b.insert(TEST_CASE.into()); |