// 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() } } }