The methods returning an iterator are now consuming, which allows them to be nested by callers.
Showing the changes to git-object/src/commit (1 of 2 files). Show all
Unified · Split
| @@ -83,6 +83,24 @@ impl<'a> CommitRefIter<'a> { · 82 unmodified lines | |||
| 83 | _ => None, | 83 | _ => None, |
| 84 | }) | 84 | }) |
| 85 | } | 85 | } |
| 86 | |||
| 87 | /// Returns the author signature if there is no decoding error. | ||
| 88 | /// Errors are coerced into options, hiding whether there was an error or not. The caller knows if there was an error or not. | ||
| 89 | pub fn author(&mut self) -> Option<git_actor::SignatureRef<'_>> { | ||
| 90 | self.find_map(|t| match t { | ||
| 91 | Ok(Token::Author { signature }) => Some(signature), | ||
| 92 | _ => None, | ||
| 93 | }) | ||
| 94 | } | ||
| 95 | |||
| 96 | /// Returns the message if there is no decoding error. | ||
| 97 | /// Errors are coerced into options, hiding whether there was an error or not. The caller knows if there was an error or not. | ||
| 98 | pub fn message(&mut self) -> Option<&'a BStr> { | ||
| 99 | self.find_map(|t| match t { | ||
| 100 | Ok(Token::Message(msg)) => Some(msg), | ||
| 101 | _ => None, | ||
| 102 | }) | ||
| 103 | } | ||
| 86 | } | 104 | } |
| 87 | 105 | ||
| 88 | impl<'a> CommitRefIter<'a> { | 106 | impl<'a> CommitRefIter<'a> { |