History

all docs for git-commitgraph::file

Sebastian Thiel committed 5 years ago

Commit 8b262011 parent 23bba1c6 files · +54 −20Browse files

Showing the changes to git-commitgraph/src/file/commit.rs (1 of 6 files). Show all

Unified · Split

git-commitgraph/src/file/commit.rs+11−12
@@ -11,7 +11,9 @@ use std::{ · 10 unmodified lines
1111 slice::Chunks,
1212 };
1313
14+/// The error used in the [`file::commit`][self] module.
1415 #[derive(thiserror::Error, Debug)]
16+#[allow(missing_docs)]
1517 pub enum Error {
1618 #[error("commit {0}'s extra edges overflows the commit-graph file's extra edges list")]
1719 ExtraEdgesListOverflow(owned::Id),
@@ -28,6 +30,7 @@ pub enum Error { · 10 unmodified lines
2830 const NO_PARENT: u32 = 0x7000_0000;
2931 const EXTENDED_EDGES_MASK: u32 = 0x8000_0000;
3032
33+/// A commit as stored in a [`File`].
3134 pub struct Commit<'a> {
3235 file: &'a File,
3336 pos: file::Position,
@@ -68,6 +71,7 @@ impl<'a> Commit<'a> { · 34 unmodified lines
6871 self.generation
6972 }
7073
74+ /// Returns an iterator over the parent positions for lookup in the owning [Graph][crate::Graph].
7175 pub fn iter_parents(&'a self) -> impl Iterator<Item = Result<graph::Position, Error>> + 'a {
7276 // I didn't find a combinator approach that a) was as strict as ParentIterator, b) supported
7377 // fuse-after-first-error behavior, and b) was significantly shorter or more understandable
@@ -78,29 +82,23 @@ impl<'a> Commit<'a> { · 4 unmodified lines
7882 }
7983 }
8084
81− // Allow the return value to outlive this Commit object, as it only needs to be bound by the
82− // lifetime of the parent file.
83− pub fn id<'b>(&'b self) -> borrowed::Id<'a>
84− where
85− 'a: 'b,
86− {
85+ /// Returns the hash of this commit.
86+ pub fn id(&self) -> borrowed::Id<'a> {
8787 self.file.id_at(self.pos)
8888 }
8989
90+ /// Returns the first parent of this commit.
9091 pub fn parent1(&self) -> Result<Option<graph::Position>, Error> {
9192 self.iter_parents().next().transpose()
9293 }
9394
95+ /// Returns the position at which this commit is stored in the parent [File].
9496 pub fn position(&self) -> file::Position {
9597 self.pos
9698 }
9799
98− // Allow the return value to outlive this Commit object, as it only needs to be bound by the
99− // lifetime of the parent file.
100− pub fn root_tree_id<'b>(&'b self) -> borrowed::Id<'a>
101− where
102− 'a: 'b,
103− {
100+ /// Return the hash of the tree this commit points to.
101+ pub fn root_tree_id(&self) -> borrowed::Id<'a> {
104102 self.root_tree_id
105103 }
106104 }
@@ -128,6 +126,7 @@ impl<'a> PartialEq for Commit<'a> { · 21 unmodified lines
128126 }
129127 }
130128
129+/// An iterator over parents of a [`Commit`].
131130 pub struct ParentIterator<'a> {
132131 commit_data: &'a Commit<'a>,
133132 state: ParentIteratorState<'a>,