1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::{Body, Comment};

/// A `Fragment` from the [`CommitMessage`], either a comment or body
#[derive(Clone, Debug, PartialEq)]
pub enum Fragment {
    Body(Body),
    Comment(Comment),
}

impl From<Body> for Fragment {
    fn from(body: Body) -> Self {
        Self::Body(body)
    }
}

impl From<&Body> for Fragment {
    fn from(body: &Body) -> Self {
        body.clone().into()
    }
}

impl From<Comment> for Fragment {
    fn from(comment: Comment) -> Self {
        Self::Comment(comment)
    }
}

impl From<&Comment> for Fragment {
    fn from(comment: &Comment) -> Self {
        comment.clone().into()
    }
}