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
55 use git_hash::{oid, ObjectId};
66 use git_object::{immutable, tree};
77 use quick_error::quick_error;
8−use std::collections::VecDeque;
8+use std::{borrow::BorrowMut, collections::VecDeque};
99
1010 quick_error! {
1111 #[derive(Debug)]
@@ -42,17 +42,19 @@ impl<'a> visit::Changes<'a> { · 30 unmodified lines
4242 /// * cycle checking is not performed, but can be performed in the delegate
4343 /// * [ManuallyDrop] is used because `Peekable` is needed. When using it as wrapper around our no-drop iterators, all of the sudden
4444 /// 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>(
4646 mut self,
4747 other: immutable::TreeIter<'a>,
48− state: &mut visit::State<R::PathId>,
48+ mut state: StateMut,
4949 mut locate: LocateFn,
5050 delegate: &mut R,
5151 ) -> Result<(), Error>
5252 where
5353 LocateFn: for<'b> FnMut(&oid, &'b mut Vec<u8>) -> Option<immutable::tree::TreeIter<'b>>,
5454 R: visit::Record,
55+ StateMut: BorrowMut<visit::State<R::PathId>>,
5556 {
57+ let state = state.borrow_mut();
5658 state.clear();
5759 let mut lhs_entries = peekable(self.0.take().unwrap_or_default());
5860 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