Skip to content

Commit

Permalink
feat: display for object::tree::EntryRef (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 3, 2022
1 parent 4f4bba2 commit b47bbb7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions git-repository/src/object/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,19 @@ mod iter {
}
}

impl<'repo, 'a> std::fmt::Display for EntryRef<'repo, 'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{:06o} {:>6} {}\t{}",
self.mode() as u32,
self.mode().as_str(),
self.id().shorten_or_id(),
self.filename()
)
}
}

impl<'repo> Tree<'repo> {
/// Return an iterator over tree entries.
pub fn iter(&self) -> impl Iterator<Item = Result<EntryRef<'repo, '_>, git_object::decode::Error>> {
Expand Down

0 comments on commit b47bbb7

Please sign in to comment.