pub struct MessageRef<'a> {
pub title: &'a BStr,
pub body: Option<&'a BStr>,
}
Expand description
A parsed commit message that assumes a title separated from the body by two consecutive newlines.
Titles can have any amount of whitespace
Fields§
§title: &'a BStr
The title of the commit, as separated from the body with two consecutive newlines. The newlines are not included.
body: Option<&'a BStr>
All bytes not consumed by the title, excluding the separating newlines.
The body is None
if there was now title separation or the body was empty after the separator.
Implementations§
Source§impl<'a> MessageRef<'a>
impl<'a> MessageRef<'a>
Sourcepub fn from_bytes(input: &'a [u8]) -> Self
pub fn from_bytes(input: &'a [u8]) -> Self
Parse the given input
as message.
Note that this cannot fail as everything will be interpreted as title if there is no body separator.
Sourcepub fn summary(&self) -> Cow<'a, BStr>
pub fn summary(&self) -> Cow<'a, BStr>
Produce a short commit summary for the message title.
This means the following
- Take the subject line which is delimited by two newlines (\n\n)
- transform intermediate consecutive whitespace including \r into one space
The resulting summary will have folded whitespace before a newline into spaces and stopped that process once two consecutive newlines are encountered.
Trait Implementations§
Source§impl<'a> Clone for MessageRef<'a>
impl<'a> Clone for MessageRef<'a>
Source§fn clone(&self) -> MessageRef<'a>
fn clone(&self) -> MessageRef<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more