teo_parser/ast/
code_comment.rs

1use crate::{declare_node, impl_node_defaults};
2use crate::format::Writer;
3use crate::traits::write::Write;
4
5declare_node!(CodeComment, pub(crate) lines: Vec<String>);
6
7impl_node_defaults!(CodeComment);
8
9impl CodeComment {
10
11    pub fn lines(&self) -> &Vec<String> {
12        &self.lines
13    }
14}
15
16impl Write for CodeComment {
17    fn write<'a>(&'a self, writer: &mut Writer<'a>) {
18        let mut contents = vec![];
19        for line in self.lines() {
20            contents.push("//");
21            contents.push(line.as_str());
22            contents.push("\n");
23        }
24        writer.write_contents(self, contents);
25    }
26}