pub struct Comment<'a> { /* private fields */ }
Expand description
A single comment from a CommitMessage
Implementations§
Source§impl Comment<'_>
impl Comment<'_>
Sourcepub fn append(&self, additional: &Self) -> Self
pub fn append(&self, additional: &Self) -> Self
Append one Comment
onto another
§Arguments
additional
- The comment to append to this one
§Returns
A new comment with the content of both comments separated by a newline
§Examples
use indoc::indoc;
use mit_commit::Comment;
assert_eq!(
Comment::from(indoc!(
"
Example 1
Example 2"
)),
Comment::from("Example 1").append(&Comment::from("Example 2"))
)
Sourcepub fn is_legal_comment_char(character: char) -> bool
pub fn is_legal_comment_char(character: char) -> bool
Checks if a given character is a valid comment character
§Arguments
character
- The character to check
§Returns
true
if the character is a valid comment character, false
otherwise
§Examples
use mit_commit::Comment;
assert!(!Comment::is_legal_comment_char('?'));
assert!(Comment::is_legal_comment_char('#'));
Trait Implementations§
Source§impl<'a> From<Comment<'a>> for Fragment<'a>
impl<'a> From<Comment<'a>> for Fragment<'a>
Source§fn from(comment: Comment<'a>) -> Self
fn from(comment: Comment<'a>) -> Self
Create a Fragment from a Comment
§Arguments
comment
- The comment to convert into a fragment
§Returns
A new Fragment::Comment
variant containing the provided comment
§Examples
use mit_commit::{Comment, Fragment};
let comment = Comment::from("# Example comment");
let fragment = Fragment::from(comment.clone());
assert_eq!(fragment, Fragment::Comment(comment));
impl<'a> Eq for Comment<'a>
impl<'a> StructuralPartialEq for Comment<'a>
Auto Trait Implementations§
impl<'a> Freeze for Comment<'a>
impl<'a> RefUnwindSafe for Comment<'a>
impl<'a> Send for Comment<'a>
impl<'a> Sync for Comment<'a>
impl<'a> Unpin for Comment<'a>
impl<'a> UnwindSafe for Comment<'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