Showing the changes to git-object/src/commit (2 of 10 files). Show all
Unified · Split
| @@ -1,9 +1,7 @@ | ||
| 1 | 1 | use bstr::{BStr, ByteSlice}; |
| 2 | 2 | |
| 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}; | |
| 7 | 5 | |
| 8 | 6 | mod decode; |
| 9 | 7 | |
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | use std::borrow::Cow; |
| 2 | 2 | |
| 3 | 3 | use bstr::BStr; |
| 4 | +use git_hash::{oid, ObjectId}; | |
| 4 | 5 | use nom::{ |
| 5 | 6 | branch::alt, |
| 6 | 7 | bytes::complete::is_not, |
| @@ -8,21 +9,20 @@ use nom::{ · 1 unmodified line | ||
| 8 | 9 | error::context, |
| 9 | 10 | }; |
| 10 | 11 | |
| 11 | −use git_hash::{oid, ObjectId}; | |
| 12 | − | |
| 13 | −use crate::commit::decode; | |
| 14 | 12 | use crate::{ |
| 15 | 13 | bstr::ByteSlice, |
| 14 | + commit::decode, | |
| 16 | 15 | immutable::{object, parse, parse::NL}, |
| 16 | + CommitRefIter, | |
| 17 | 17 | }; |
| 18 | 18 | |
| 19 | 19 | #[derive(Copy, Clone)] |
| 20 | −enum SignatureKind { | |
| 20 | +pub(crate) enum SignatureKind { | |
| 21 | 21 | Author, |
| 22 | 22 | Committer, |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | −enum State { | |
| 25 | +pub(crate) enum State { | |
| 26 | 26 | Tree, |
| 27 | 27 | Parents, |
| 28 | 28 | Signature { of: SignatureKind }, |
| @@ -37,13 +37,6 @@ impl Default for State { · 8 unmodified lines | ||
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
| 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 | − | |
| 47 | 40 | impl<'a> CommitRefIter<'a> { |
| 48 | 41 | /// Create a commit iterator from data. |
| 49 | 42 | pub fn from_bytes(data: &'a [u8]) -> CommitRefIter<'a> { |
| @@ -198,7 +191,7 @@ impl<'a> Iterator for CommitRefIter<'a> { · 148 unmodified lines | ||
| 198 | 191 | } |
| 199 | 192 | } |
| 200 | 193 | |
| 201 | −/// A token returned by the [commit iterator][RefIter]. | |
| 194 | +/// A token returned by the [commit iterator][CommitRefIter]. | |
| 202 | 195 | #[allow(missing_docs)] |
| 203 | 196 | #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)] |
| 204 | 197 | pub enum Token<'a> { |