History

[changes] more flexible handle of state

Sebastian Thiel committed 5 years ago

Commit 11db16b1 parent e1a35aa3 files · +10 −6Browse files

Showing the changes to git-diff/src (1 of 3 files). Show all

Unified · Split

git-diff/src/visit/changes.rs+5−3
@@ -5,7 +5,7 @@ use crate::{ · 4 unmodified lines
5use git_hash::{oid, ObjectId};5use git_hash::{oid, ObjectId};
6use git_object::{immutable, tree};6use git_object::{immutable, tree};
7use quick_error::quick_error;7use quick_error::quick_error;
8use std::collections::VecDeque;8use std::{borrow::BorrowMut, collections::VecDeque};
9 9
10quick_error! {10quick_error! {
11 #[derive(Debug)]11 #[derive(Debug)]
@@ -42,17 +42,19 @@ impl<'a> visit::Changes<'a> { · 30 unmodified lines
42 /// * cycle checking is not performed, but can be performed in the delegate42 /// * cycle checking is not performed, but can be performed in the delegate
43 /// * [ManuallyDrop] is used because `Peekable` is needed. When using it as wrapper around our no-drop iterators, all of the sudden43 /// * [ManuallyDrop] is used because `Peekable` is needed. When using it as wrapper around our no-drop iterators, all of the sudden
44 /// borrowcheck complains as Drop is present (even though it's not)44 /// borrowcheck complains as Drop is present (even though it's not)
45 pub fn needed_to_obtain<LocateFn, R>(45 pub fn needed_to_obtain<LocateFn, R, StateMut>(
46 mut self,46 mut self,
47 other: immutable::TreeIter<'a>,47 other: immutable::TreeIter<'a>,
48 state: &mut visit::State<R::PathId>,48 mut state: StateMut,
49 mut locate: LocateFn,49 mut locate: LocateFn,
50 delegate: &mut R,50 delegate: &mut R,
51 ) -> Result<(), Error>51 ) -> Result<(), Error>
52 where52 where
53 LocateFn: for<'b> FnMut(&oid, &'b mut Vec<u8>) -> Option<immutable::tree::TreeIter<'b>>,53 LocateFn: for<'b> FnMut(&oid, &'b mut Vec<u8>) -> Option<immutable::tree::TreeIter<'b>>,
54 R: visit::Record,54 R: visit::Record,
55 StateMut: BorrowMut<visit::State<R::PathId>>,
55 {56 {
57 let state = state.borrow_mut();
56 state.clear();58 state.clear();
57 let mut lhs_entries = peekable(self.0.take().unwrap_or_default());59 let mut lhs_entries = peekable(self.0.take().unwrap_or_default());
58 let mut rhs_entries = peekable(other);60 let mut rhs_entries = peekable(other);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t