cbor_cli/traits.rs
1use std::io::{self, Stdout};
2
3/// A generic write method for a specific type.
4pub trait WriteStr<T> {
5 fn write_str(&mut self, target: T) -> io::Result<()>;
6}
7
8/// If they write to the Terminal, then write to Stdout.
9impl<T: std::fmt::Display> WriteStr<T> for Stdout {
10 fn write_str(&mut self, target: T) -> io::Result<()> {
11 println!("{}", target);
12 Ok(())
13 }
14}