1pub use self::kinds::PrimaryColor;
6pub use self::kinds::SecondaryColor;
7pub use self::utils::mix;
8
9pub mod kinds {
10 pub enum PrimaryColor {
12 Red,
13 Yellow,
14 Blue,
15 }
16
17 pub enum SecondaryColor {
19 Orange,
20 Green,
21 Purple,
22 }
23}
24
25pub mod utils {
26 use crate::kinds::*;
27
28 pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
31 use PrimaryColor::*;
32 use SecondaryColor::*;
33
34 match (c1, c2) {
35 (Red, Yellow) | (Yellow, Red) => Orange,
36 (Yellow, Blue) | (Blue, Yellow) => Green,
37 (Red, Blue) | (Blue, Red) => Purple,
38 _ => panic!("Cannot mix the same primary color to get a secondary color"),
39 }
40 }
41}