html_node_core/node/
comment.rs1use std::fmt::{self, Display, Formatter};
2
3#[derive(Debug, Clone, PartialEq, Eq)]
9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10pub struct Comment {
11 pub comment: String,
17}
18
19impl Display for Comment {
20 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
22 write!(f, "<!-- {} -->", self.comment)
23 }
24}
25
26impl<C> From<C> for Comment
27where
28 C: Into<String>,
29{
30 fn from(comment: C) -> Self {
32 Self {
33 comment: comment.into(),
34 }
35 }
36}