1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// use palett::utils::ansi::{effect_to_ansi, SC, L, R};
// use std::fmt::Write;
// use palett::enums::Effect;
//
// pub struct Dye {
// head: String,
// tail: String,
// }
//
//
// impl Dye {
// fn build() -> Dye {
// Dye { head: "".to_string(), tail: "".to_string() }
// }
// fn assign_effects<'a, I>(&mut self, effects: I) -> &Dye where
// I: IntoIterator<Item=&'a Effect>
// {
// // let iter = effects.into_iter();
// for effect in effects.into_iter() {
// let (h, t) = effect_to_ansi(effect);
// let h = h.to_owned();
// let t = t.to_owned();
// write!(&mut self.head, "{}{}", SC, h).unwrap(); // &mut self.head.push_str(&*(SC.to_owned() + h));
// write!(&mut self.tail, "{}{}", SC, t).unwrap(); // &mut self.tail.push_str(&*(SC.to_owned() + t));
// }
// self
// }
// }
//
// // fn enclose(text: &str) -> String {
// // return format!("{}{}{}", L, text, R);
// // }
//
// impl Fn<(&str, )> for Dye {
// extern "rust-call" fn call(&self, args: (&str, )) -> String {
// let (text, ) = args;
// return format!("{}{}{}{}{}{}{}", L, &self.head, R, text, L, &self.tail, R);
// }
// }
//
// impl FnMut<(&str, )> for Dye {
// extern "rust-call" fn call_mut(&mut self, args: (&str, )) -> String {
// self.call(args)
// // let (text, ) = args;
// // return format!("{}{}{}", self.head, text, self.tail);
// }
// }
//
// impl FnOnce<(&str, )> for Dye {
// type Output = String;
// extern "rust-call" fn call_once(self, args: (&str, )) -> String {
// self.call(args)
// // let (text, ) = args;
// // return format!("{}{}{}", self.head, text, self.tail);
// }
// }
//
// #[cfg(test)]
// mod dye_tests {
// use palett::dye::DyeFactory;
// use palett::enums::Effect;
//
// // #[test]
// // fn test() {
// // // let mut dye = Dye { head: "".to_string(), tail: "".to_string() };
// // let mut dye = Dye::build();
// // let effects = vec![&Effects::Bold];
// // (&mut dye).assign_effects(&mut effects.into_iter());
// // println!("{}", dye("some"));
// // }
//
// #[test]
// fn test() {
// // let mut dye = Dye { head: "".to_string(), tail: "".to_string() };
// let mut dye = DyeFactory::build();
// let effects = vec![&Effect::Bold];
// let some = (&mut dye).assign_effects(&effects);
// println!("{}", dye("some"));
// }
// }