History

[object #177] commit::RefIter -> CommitRefIter

Sebastian Thiel committed 5 years ago

Commit e6033061 parent 45d393410 files · +27 −35Browse files

Showing the changes to git-object/src/commit (2 of 10 files). Show all

Unified · Split

2 files
  1. git-object/src/commit/mod.rs +2 −4
  2. git-object/src/commit/ref_iter.rs +6 −13
git-object/src/commit/mod.rs+2−4
@@ -1,9 +1,7 @@
11 use bstr::{BStr, ByteSlice};
22
3−pub use ref_iter::RefIter;
4−
5−use crate::{immutable, TagRef};
6−use crate::{immutable::object, CommitRef};
3+pub use crate::CommitRefIter;
4+use crate::{immutable, immutable::object, CommitRef, TagRef};
75
86 mod decode;
97
git-object/src/commit/ref_iter.rs+6−13
@@ -1,6 +1,7 @@
11 use std::borrow::Cow;
22
33 use bstr::BStr;
4+use git_hash::{oid, ObjectId};
45 use nom::{
56 branch::alt,
67 bytes::complete::is_not,
@@ -8,21 +9,20 @@ use nom::{ · 1 unmodified line
89 error::context,
910 };
1011
11−use git_hash::{oid, ObjectId};
12−
13−use crate::commit::decode;
1412 use crate::{
1513 bstr::ByteSlice,
14+ commit::decode,
1615 immutable::{object, parse, parse::NL},
16+ CommitRefIter,
1717 };
1818
1919 #[derive(Copy, Clone)]
20−enum SignatureKind {
20+pub(crate) enum SignatureKind {
2121 Author,
2222 Committer,
2323 }
2424
25−enum State {
25+pub(crate) enum State {
2626 Tree,
2727 Parents,
2828 Signature { of: SignatureKind },
@@ -37,13 +37,6 @@ impl Default for State { · 8 unmodified lines
3737 }
3838 }
3939
40−/// Like [`CommitRef`][crate::CommitRef], but as `Iterator` to support (up to) entirely allocation free parsing.
41−/// It's particularly useful to traverse the commit graph without ever allocating arrays for parents.
42−pub struct CommitRefIter<'a> {
43− data: &'a [u8],
44− state: State,
45−}
46−
4740 impl<'a> CommitRefIter<'a> {
4841 /// Create a commit iterator from data.
4942 pub fn from_bytes(data: &'a [u8]) -> CommitRefIter<'a> {
@@ -198,7 +191,7 @@ impl<'a> Iterator for CommitRefIter<'a> { · 148 unmodified lines
198191 }
199192 }
200193
201−/// A token returned by the [commit iterator][RefIter].
194+/// A token returned by the [commit iterator][CommitRefIter].
202195 #[allow(missing_docs)]
203196 #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
204197 pub enum Token<'a> {