History

git-commitgraph with a more convenient public interface with AsRef(#63)

Sebastian Thiel committed 5 years ago

Commit ba04e4e1 parent 0b729662 files · +6 −5Browse files

Showing the changes to git-commitgraph/src/graph (1 of 2 files). Show all

Unified · Split

git-commitgraph/src/graph/access.rs+4−4
@@ -15,8 +15,8 @@ impl Graph { · 14 unmodified lines
1515 }
1616
1717 /// Returns the commit matching the given `id`.
18− pub fn commit_by_id(&self, id: &git_hash::oid) -> Option<Commit<'_>> {
19− let r = self.lookup_by_id(id)?;
18+ pub fn commit_by_id(&self, id: impl AsRef<git_hash::oid>) -> Option<Commit<'_>> {
19+ let r = self.lookup_by_id(id.as_ref())?;
2020 Some(r.file.commit_at(r.file_pos))
2121 }
2222
@@ -40,8 +40,8 @@ impl Graph { · 17 unmodified lines
4040 }
4141
4242 /// Translate the given `id` to its position in the file.
43− pub fn lookup(&self, id: &git_hash::oid) -> Option<graph::Position> {
44− Some(self.lookup_by_id(id)?.graph_pos)
43+ pub fn lookup(&self, id: impl AsRef<git_hash::oid>) -> Option<graph::Position> {
44+ Some(self.lookup_by_id(id.as_ref())?.graph_pos)
4545 }
4646
4747 /// Returns the number of commits stored in this file.