test_sk_crate 0.1.0

A fun game where you guess what number the computer has chosen.
Documentation
// //! # My Crate
// //!
// //! `my_crate` is a collection of utilities to make performing certain
// //! calculations more convenient.

// /// Adds one to the number given.
// ///
// /// # Examples
// ///
// /// ```
// /// let arg = 5;
// /// let answer = my_crate::add_one(arg);
// ///
// /// assert_eq!(6, answer);
// /// ```
// pub fn add_one(x: i32) -> i32 { x + 1 }

//! # Art
//!
//! A library for modeling artistic concepts.

pub use self::kinds::{PrimaryColor, SecondaryColor};
pub use self::utils::mix;
// exporting the items at top-level

pub mod kinds {
    /// The primary colors according to the RYB color model.
    pub enum PrimaryColor {
        Red,
        Yellow,
        Blue,
    }

    /// The secondary colors according to the RYB color model.
    pub enum SecondaryColor {
        Orange,
        Green,
        Purple,
    }
}

pub mod utils {
    use crate::kinds::*;

    /// Combines two primary colors in equal amounts to create
    /// a secondary color.
    pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
        match (c1, c2) {
            // If the first color is Red and the second color is Yellow, return Orange
            (PrimaryColor::Red, PrimaryColor::Yellow) => SecondaryColor::Orange,
            // If the first color is Red and the second color is Blue, return Purple
            (PrimaryColor::Red, PrimaryColor::Blue) => SecondaryColor::Purple,
            // If the first color is Yellow and the second color is Blue, return Green
            (PrimaryColor::Yellow, PrimaryColor::Blue) => SecondaryColor::Green,
            // For any other combination, return Purple
            _ => SecondaryColor::Purple,
        }
        
    }
}