WIP: List the most recent change to each top-level entry in a git tree

simplify `EntryScanner`

Signed-off-by: tjh <x@tjh.dev>
Change-Id: I6a6a6964630917cbc9aba25ace42605aa5ed3201

tjh.dev f7dfe9f1 bf8d29b5

verified
Changed files
+10 -13
src
+10 -13
src/main.rs
··· 78 78 Ok(()) 79 79 } 80 80 81 - struct EntryScanner<'repo, 'a, C, P> { 82 - current_tree: C, 83 - parent_tree: P, 81 + struct EntryScanner<'repo, 'a, I> { 82 + current_tree: I, 84 83 current_entry: Option<EntryRef<'repo, 'a>>, 84 + parent_tree: I, 85 85 parent_entry: Option<EntryRef<'repo, 'a>>, 86 86 } 87 87 88 - impl<'repo, 'a, C, P> EntryScanner<'repo, 'a, C, P> 88 + impl<'repo, 'a, I> EntryScanner<'repo, 'a, I> 89 89 where 90 - C: Iterator<Item = Result<EntryRef<'repo, 'a>, DecodeError>>, 91 - P: Iterator<Item = Result<EntryRef<'repo, 'a>, DecodeError>>, 90 + I: Iterator<Item = Result<EntryRef<'repo, 'a>, DecodeError>>, 92 91 { 93 - pub fn new(current_tree: C, parent_tree: P) -> Result<Self, DecodeError> { 92 + pub fn new(current_tree: I, parent_tree: I) -> Result<Self, DecodeError> { 94 93 let mut this = Self { 95 94 current_tree, 96 95 parent_tree, ··· 129 128 while !self.is_complete() { 130 129 match (&self.current_entry, &self.parent_entry) { 131 130 (None, None) => break, 132 - (Some(head_entry), Some(parent_entry)) 133 - if head_entry.filename() == parent_entry.filename() => 134 - { 135 - if head_entry.id() != parent_entry.id() { 131 + (Some(current), Some(parent)) if current.filename() == parent.filename() => { 132 + if current.id() != parent.id() { 136 133 return Ok(self 137 134 .advance_both()? 138 135 .0 ··· 141 138 self.advance_both()?; 142 139 continue; 143 140 } 144 - (Some(head_entry), Some(parent_entry)) => { 145 - if head_entry.filename() < parent_entry.filename() { 141 + (Some(current), Some(parent)) => { 142 + if current.filename() < parent.filename() { 146 143 return Ok(self 147 144 .advance_current()? 148 145 .map(|entry| Change::Create(entry.detach())));