1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std::io;

/// A generic write method for a specific type.
pub trait TypeWrite<T> {
  fn write(&mut self, target: T) -> io::Result<()>;
}

/// Represents Stdout.
pub struct Terminal {}

/// If they write to the Terminal, then write to Stdout.
impl<T: std::fmt::Display> TypeWrite<T> for Terminal {
  fn write(&mut self, target: T) -> io::Result<()> {
    println!("{}", target);
    Ok(())
  }
}

pub enum TypeWriter {
  Terminal(Terminal),
}