code-gen 0.10.0

This library aids in code generation.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::CodeBuffer;

/// Code within a single line.
pub trait Expression {
    /// Writes the code to the buffer `b`.
    fn write(&self, b: &mut CodeBuffer);

    /// Renders the expression to a string.
    fn to_code(&self) -> String {
        let mut b = CodeBuffer::default();
        self.write(&mut b);
        b.into()
    }
}