code_gen/expression/expression.rs
1use crate::CodeBuffer;
2
3/// Code within a single line.
4pub trait Expression {
5 /// Writes the code to the buffer `b`.
6 fn write(&self, b: &mut CodeBuffer);
7
8 /// Renders the expression to a string.
9 fn to_code(&self) -> String {
10 let mut b = CodeBuffer::default();
11 self.write(&mut b);
12 b.into()
13 }
14}