…but it doesn't work because it thinks there is a destructor present, even though it's not. These are implemented for Rc/Box/Arc versions of the iterator, but not for the bare one.
Showing the changes to git-diff/src (1 of 1 file). Show all
Unified · Split
| @@ -51,8 +51,8 @@ impl<'a> visit::Changes<'a> { · 50 unmodified lines | ||
| 51 | 51 | R: visit::Record, |
| 52 | 52 | { |
| 53 | 53 | state.clear(); |
| 54 | − let mut lhs_entries = self.0.take().unwrap_or_default(); | |
| 55 | − let mut rhs_entries = other; | |
| 54 | + let mut lhs_entries = self.0.take().unwrap_or_default().peekable(); | |
| 55 | + let mut rhs_entries = other.peekable(); | |
| 56 | 56 | let mut avoid_popping_path: Option<()> = None; |
| 57 | 57 | |
| 58 | 58 | dbg!("================= START ==================="); |
| @@ -65,16 +65,24 @@ impl<'a> visit::Changes<'a> { · 6 unmodified lines | ||
| 65 | 65 | match state.trees.pop_front() { |
| 66 | 66 | Some((None, Some(rhs))) => { |
| 67 | 67 | delegate.set_current_path(rhs.parent_path_id.clone()); |
| 68 | − rhs_entries = locate(&rhs.tree_id, &mut state.buf2).ok_or(Error::NotFound(rhs.tree_id))?; | |
| 68 | + rhs_entries = locate(&rhs.tree_id, &mut state.buf2) | |
| 69 | + .ok_or(Error::NotFound(rhs.tree_id))? | |
| 70 | + .peekable(); | |
| 69 | 71 | } |
| 70 | 72 | Some((Some(lhs), Some(rhs))) => { |
| 71 | 73 | delegate.set_current_path(lhs.parent_path_id.clone()); |
| 72 | − lhs_entries = locate(&lhs.tree_id, &mut state.buf1).ok_or(Error::NotFound(lhs.tree_id))?; | |
| 73 | − rhs_entries = locate(&rhs.tree_id, &mut state.buf2).ok_or(Error::NotFound(rhs.tree_id))?; | |
| 74 | + lhs_entries = locate(&lhs.tree_id, &mut state.buf1) | |
| 75 | + .ok_or(Error::NotFound(lhs.tree_id))? | |
| 76 | + .peekable(); | |
| 77 | + rhs_entries = locate(&rhs.tree_id, &mut state.buf2) | |
| 78 | + .ok_or(Error::NotFound(rhs.tree_id))? | |
| 79 | + .peekable(); | |
| 74 | 80 | } |
| 75 | 81 | Some((Some(lhs), None)) => { |
| 76 | 82 | delegate.set_current_path(lhs.parent_path_id.clone()); |
| 77 | − lhs_entries = locate(&lhs.tree_id, &mut state.buf1).ok_or(Error::NotFound(lhs.tree_id))?; | |
| 83 | + lhs_entries = locate(&lhs.tree_id, &mut state.buf1) | |
| 84 | + .ok_or(Error::NotFound(lhs.tree_id))? | |
| 85 | + .peekable(); | |
| 78 | 86 | } |
| 79 | 87 | Some((None, None)) => unreachable!("BUG: it makes no sense to fill the stack with empties"), |
| 80 | 88 | None => return Ok(()), |
| @@ -189,13 +197,13 @@ impl<'a> visit::Changes<'a> { · 108 unmodified lines | ||
| 189 | 197 | }; |
| 190 | 198 | } |
| 191 | 199 | Less => { |
| 192 | − let mut cursor = lhs; | |
| 200 | + let cursor = lhs; | |
| 193 | 201 | loop { |
| 194 | 202 | delete_entry_schedule_recursion(&cursor, &mut state.trees, delegate)?; |
| 195 | 203 | |
| 196 | 204 | match lhs_entries.next() { |
| 197 | 205 | Some(entry) => { |
| 198 | − let entry = entry?; | |
| 206 | + let _entry = entry?; | |
| 199 | 207 | // if entry.filename == rhs. |
| 200 | 208 | todo!("peek entry, see if we caught up, ") |
| 201 | 209 | } |