code_gen/statement/statement.rs
1use crate::CodeBuffer;
2
3/// Code that spans one or more lines.
4pub trait Statement {
5 /// Writes the code to the buffer `b` at the indent `level`.
6 fn write(&self, b: &mut CodeBuffer, level: usize);
7
8 /// Renders the statement to a string at indent level 0.
9 fn to_code(&self) -> String {
10 let mut b = CodeBuffer::default();
11 self.write(&mut b, 0);
12 b.into()
13 }
14}