1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
use crate::{CodeBuffer, Expression, Statement};
/// A statement that wraps an expression.
pub struct ExpressionStatement<E: Expression> {
expression: E,
}
impl<E: Expression> From<E> for ExpressionStatement<E> {
fn from(expression: E) -> Self {
Self { expression }
}
}
impl<E: Expression> Statement for ExpressionStatement<E> {
fn write(&self, b: &mut CodeBuffer, level: usize) {
b.indent(level);
self.expression.write(b);
b.end_line();
}
}