pub struct Body<'a> { /* private fields */ }
Expand description
A single contiguous block of [CommitMessage
] text
Implementations§
Source§impl Body<'_>
impl Body<'_>
Sourcepub fn append(&self, additional: &Self) -> Self
pub fn append(&self, additional: &Self) -> Self
Append one Body
onto another
§Arguments
additional
- The body to append to this one
§Returns
A new body with the content of both bodies separated by a newline
§Examples
use indoc::indoc;
use mit_commit::Body;
assert_eq!(
Body::from(indoc!(
"
Example 1
Example 2"
)),
Body::from("Example 1").append(&Body::from("Example 2"))
)
Trait Implementations§
Source§impl<'a> From<Body<'a>> for Fragment<'a>
impl<'a> From<Body<'a>> for Fragment<'a>
Source§fn from(body: Body<'a>) -> Self
fn from(body: Body<'a>) -> Self
Create a Fragment from a Body
§Arguments
body
- The body to convert into a fragment
§Returns
A new Fragment::Body
variant containing the provided body
§Examples
use mit_commit::{Body, Fragment};
let body = Body::from("Example body");
let fragment = Fragment::from(body.clone());
assert_eq!(fragment, Fragment::Body(body));
Source§impl<'a> From<Cow<'a, str>> for Body<'a>
impl<'a> From<Cow<'a, str>> for Body<'a>
Source§fn from(body: Cow<'a, str>) -> Self
fn from(body: Cow<'a, str>) -> Self
Create a Body from a Cow<_, str>
§Arguments
body
- The string content to create the body from
§Returns
A new Body containing the provided string
§Examples
use std::borrow::Cow;
use mit_commit::Body;
let expected = "a string";
let input = Cow::from(expected);
assert_eq!(Body::from(input).to_string(), expected)
impl<'a> Eq for Body<'a>
impl<'a> StructuralPartialEq for Body<'a>
Auto Trait Implementations§
impl<'a> Freeze for Body<'a>
impl<'a> RefUnwindSafe for Body<'a>
impl<'a> Send for Body<'a>
impl<'a> Sync for Body<'a>
impl<'a> Unpin for Body<'a>
impl<'a> UnwindSafe for Body<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more