initial
This commit is contained in:
33
src/output.rs
Normal file
33
src/output.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
// 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user