1
2extern crate clucolor;
3
4use clucolor::cluColor;
5use clucolor::colors::BrightRed;
6use std::time::SystemTime;
7
8fn main() {
9
10 let time_start = SystemTime::now();
11 println!("Start time {:?} nanos", time_start.elapsed().unwrap().subsec_nanos());
12
13 let writer = MyWriter::new(time_start);
14 writer.println("OK");
15 writer.println("OK12");
16 writer.println("OK123");
17}
18
19
20#[derive(Debug)]
21pub struct MyWriter {
22 time: SystemTime,
23}
24
25impl MyWriter {
26 #[inline]
27 pub fn new(time: SystemTime) -> MyWriter {
28 MyWriter {
29 time: time,
30 }
31 }
32
33 #[inline]
34 pub fn string<'a>(&self, str: &'a str) -> String {
35 BrightRed::string_fmt( format_args!("[{:?} nanos] {}", SystemTime::now().elapsed().unwrap().subsec_nanos(), str) )
36 }
37
38 pub fn println<'a>(&self, str: &'a str) {
39 println!("{}", self.string(str));
40 }
41}
42
43
44