with_color/
with_color.rs

1
2extern crate clucolor;
3use clucolor::colors::BrightBlue;
4use clucolor::colors::BrightRed;
5use clucolor::colors::BrightGreen;
6use clucolor::cluColor;
7
8pub fn main() {
9	//Experimental possibility of using Rust Arguments for cluColors.
10
11     let mut item = Items::default();
12
13     for a in 0..15 {
14          BrightBlue::with_color_fmt(format_args!("ITEM #{:?}", item), |fmt| {
15               println!("NUM #{}, {}; COUNT: {}", a, fmt, item.count());
16          });
17          
18          item.0 += 1;
19          item.1 += 2;
20     }
21
22
23     for a in 0..15 {
24          BrightGreen::with_color_fmt(format_args!("NUM #{}", a), |fmt_num| {
25               BrightBlue::with_color_fmt(format_args!("ITEM #{:?}", item), |fmt_item| {
26                    BrightRed::with_color_fmt(format_args!("ALL_COUNT {}", item.count()), |fmt_count| {
27                         println!("{}, {}; {};", fmt_num, fmt_item, fmt_count);
28                    });
29               });
30          });
31
32          item.0 += 1;
33          item.1 += 2;
34     }
35}
36
37#[derive(Debug, Default)]
38pub struct Items(usize, usize);
39
40impl Items {
41     #[inline]
42     pub fn count(&self) -> usize {
43          self.0 + self.1
44     }
45}