pub use self::color::PrimaryColor;
pub use self::color::SecondaryColor;
pub use self::mix_utils::mix;
pub mod color {
#[derive(Debug)]
pub enum PrimaryColor {
Red,
Yellow,
Blue,
}
#[derive(Debug)]
pub enum SecondaryColor {
Orange,
Green,
Purple,
}
}
pub mod mix_utils {
use super::color::{PrimaryColor, SecondaryColor};
pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
use PrimaryColor::*;
match (c1, c2) {
(Red, Yellow) | (Yellow, Red) => SecondaryColor::Orange,
(Red, Blue) | (Blue, Red) => SecondaryColor::Purple,
(Blue, Yellow) | (Yellow, Blue) => SecondaryColor::Green,
_ => panic!("Aynı renk iki kez karıştırılamaz ❌"),
}
}
}
fn main() {
let red = PrimaryColor::Red;
let blue = PrimaryColor::Blue;
let purple = mix(red, blue);
println!("Red + Blue = {:?} 💜", purple);
let yellow = PrimaryColor::Yellow;
let orange = mix(PrimaryColor::Red, yellow);
println!("Red + Yellow = {:?} 🧡", orange);
}