use crate::CodeBuffer;
use crate::rust::CommentType;
pub trait WithComments: Sized {
fn comments(&self) -> &[String];
fn add_comment<S>(&mut self, comment: S)
where
S: Into<String>;
#[must_use]
fn with_comment<S>(mut self, comment: S) -> Self
where
S: Into<String>,
{
self.add_comment(comment);
self
}
fn write_comments(&self, comment_type: CommentType, b: &mut CodeBuffer, level: usize) {
for line in self.comments() {
comment_type.write_line(b, level, line.as_str());
}
}
}