ch14_2_test_my_crate/
lib.rs

1//! # My Crate
2//!
3//! `my_crate` is a collection of utilities to make performing certain
4//! calculations more convenient.
5
6/// Adds one to the number given.
7///
8/// # Examples
9///
10/// ```
11/// let arg = 5;
12/// let answer = my_crate::add_one(arg);
13///
14/// assert_eq!(6, answer);
15/// ```
16pub fn add_one(x: i32) -> i32 {
17    x + 1
18}
19
20pub use self::kinds::PrimaryColor;
21pub use self::utils::mix;
22
23pub mod kinds {
24    /// The primary colors according to the RYB color model.
25    #[derive(Debug)] // Add this line
26    pub enum PrimaryColor {
27        Red,
28        Yellow,
29        Blue,
30    }
31}
32
33pub mod utils {
34    use crate::kinds::PrimaryColor;
35
36    /// Combines two primary colors in equal amounts to create
37    /// a secondary color.
38    pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> String {
39        format!("Mixed color: {:?} and {:?}", c1, c2)
40    }
41}