kaslan29 0.1.0

Basit bir deneme crate'i.
Documentation
//! # My Crate 🧰
//!
//! Bu crate, `PrimaryColor`, `SecondaryColor` ve `mix` fonksiyonunu kullanarak
//! renk karıştırma işlemlerini örneklemektedir 🎨
//!
//! `cargo doc --open` ile dokümantasyonu HTML olarak görebilirsiniz 🌐
//! `cargo test` ile dokümantasyon içindeki örnekler test edilir ✅

/// Renk türlerini ve karıştırma fonksiyonunu dışarıdan erişilebilir hale getiriyoruz 🪄
pub use self::color::PrimaryColor;
pub use self::color::SecondaryColor;
pub use self::mix_utils::mix;

/// Renkleri temsil eden enum ve yapılar burada tanımlıdır 🌈
pub mod color {
    /// RYB (Red-Yellow-Blue) modeline göre birincil renkler 🔴🟡🔵
    #[derive(Debug)]
    pub enum PrimaryColor {
        Red,
        Yellow,
        Blue,
    }

    /// İkincil renkler: iki birincil rengin birleşimi 🧪
    #[derive(Debug)]
    pub enum SecondaryColor {
        Orange,
        Green,
        Purple,
    }
}

/// Renkleri karıştırma fonksiyonu burada tanımlanır 🧬
pub mod mix_utils {
    use super::color::{PrimaryColor, SecondaryColor};

    /// İki birincil rengi karıştırır ve ortaya çıkan ikincil rengi döner 🎨
    ///
    /// # Examples
    ///
    /// ```
    /// use my_crate::{PrimaryColor, mix, SecondaryColor};
    ///
    /// let red = PrimaryColor::Red;
    /// let yellow = PrimaryColor::Yellow;
    /// let result = mix(red, yellow);
    ///
    /// match result {
    ///     SecondaryColor::Orange => println!("Turuncu oluştu!"),
    ///     _ => panic!("Yanlış renk karışımı!"),
    /// }
    /// ```
    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() {
    // Kullanımı örnekleyelim 🚀
    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);
}