learning_the_book/lib.rs
1//! # My Crate
2//!
3//! `my_crate` is a collection of utitlities to make performing certain calculation
4//! more convenient
5
6/// Adds one to the number given.
7///
8/// # Examples
9///
10/// ```
11/// let arg = 5;
12/// let answer = playground::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::kinds::SecondaryColor;
22pub use self::utils::mix;
23
24pub mod kinds {
25 /// The primary colors according to the RYB color model.
26 pub enum PrimaryColor {
27 Red,
28 Yellow,
29 Blue,
30 }
31
32 /// The secondary colors according to the RYB color model.
33 pub enum SecondaryColor {
34 Orange,
35 Green,
36 Purple,
37 }
38}
39
40pub mod utils {
41 use crate::kinds::*;
42
43 /// Combines two primary colors in equal amount to create
44 /// a secondary color
45 pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
46 SecondaryColor::Orange
47 }
48}