Files
soda/src/output.rs
2025-02-12 09:47:32 -05:00

33 lines
517 B
Rust

// output trait and some possibilities for outputs
pub trait Output {
fn write(&mut self, data : &str);
}
pub struct DummyOutput {
out : String
}
impl Output for DummyOutput {
fn write(&mut self, data : &str) {
self.out += data;
}
}
impl DummyOutput {
pub fn print(&mut self) {
println!("{}", self.out);
}
pub fn spool(self) -> String {
self.out
}
pub fn new() -> DummyOutput {
DummyOutput {
out : String::new()
}
}
}