1 | /// Custom color structure, it will generate a true color in the result |
2 | #[derive (Debug, Copy, Clone, PartialEq, Eq)] |
3 | pub struct CustomColor { |
4 | /// Red |
5 | pub r: u8, |
6 | /// Green |
7 | pub g: u8, |
8 | /// Blue |
9 | pub b: u8, |
10 | } |
11 | |
12 | /// This only makes custom color creation easier. |
13 | impl CustomColor { |
14 | /// Create a new custom color |
15 | pub fn new(r: u8, g: u8, b: u8) -> Self { |
16 | Self { r, g, b } |
17 | } |
18 | } |
19 | |
20 | #[cfg (test)] |
21 | mod tests { |
22 | use crate::*; |
23 | #[test ] |
24 | fn main() { |
25 | let my_color = CustomColor::new(0, 120, 120); |
26 | println!(" {}" , "Greetings from Ukraine" .custom_color(my_color)); |
27 | } |
28 | } |
29 | |