use crate::rust::Function;
use crate::{CodeBuffer, Statement};
pub trait WithFunctions: Sized {
fn functions(&self) -> &[Function];
fn add_function<F>(&mut self, function: F)
where
F: Into<Function>;
#[must_use]
fn with_function<F>(mut self, function: F) -> Self
where
F: Into<Function>,
{
self.add_function(function);
self
}
fn write_functions(&self, b: &mut CodeBuffer, level: usize) {
if let Some((first, rest)) = self.functions().split_first() {
first.write(b, level);
for function in rest {
b.end_line();
function.write(b, level);
}
}
}
}