Unified · Split
| @@ -24,6 +24,34 @@ mod write { · 23 unmodified lines | |||
| 24 | 24 | ||
| 25 | /// Convenient extraction of typed object. | 25 | /// Convenient extraction of typed object. |
| 26 | impl Object { | 26 | impl Object { |
| 27 | /// Turns this instance into a [`Blob`][Blob] if it is one. | ||
| 28 | pub fn into_blob(self) -> Option<Blob> { | ||
| 29 | match self { | ||
| 30 | Object::Blob(v) => Some(v), | ||
| 31 | _ => None, | ||
| 32 | } | ||
| 33 | } | ||
| 34 | /// Turns this instance into a [`Commit`][Commit] if it is one. | ||
| 35 | pub fn into_commit(self) -> Option<Commit> { | ||
| 36 | match self { | ||
| 37 | Object::Commit(v) => Some(v), | ||
| 38 | _ => None, | ||
| 39 | } | ||
| 40 | } | ||
| 41 | /// Turns this instance into a [`Tree`][Tree] if it is one. | ||
| 42 | pub fn into_tree(self) -> Option<Tree> { | ||
| 43 | match self { | ||
| 44 | Object::Tree(v) => Some(v), | ||
| 45 | _ => None, | ||
| 46 | } | ||
| 47 | } | ||
| 48 | /// Turns this instance into a [`Tag`][Tag] if it is one. | ||
| 49 | pub fn into_tag(self) -> Option<Tag> { | ||
| 50 | match self { | ||
| 51 | Object::Tag(v) => Some(v), | ||
| 52 | _ => None, | ||
| 53 | } | ||
| 54 | } | ||
| 27 | /// Returns a [`Blob`][Blob] if it is one. | 55 | /// Returns a [`Blob`][Blob] if it is one. |
| 28 | pub fn as_blob(&self) -> Option<&Blob> { | 56 | pub fn as_blob(&self) -> Option<&Blob> { |
| 29 | match self { | 57 | match self { |
| @@ -61,7 +61,6 @@ pub fn forward(lines: &[u8]) -> impl Iterator<Item = Result<log::LineRef<'_>, de · 60 unmodified lines | |||
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | /// An iterator yielding parsed lines in a file in reverse. | 63 | /// An iterator yielding parsed lines in a file in reverse. |
| 64 | #[allow(dead_code)] | ||
| 65 | pub struct Reverse<'a, F> { | 64 | pub struct Reverse<'a, F> { |
| 66 | buf: &'a mut [u8], | 65 | buf: &'a mut [u8], |
| 67 | count: usize, | 66 | count: usize, |