Skip to main content

my_crate_carllhw/
lib.rs

1//! # My Crate
2//!
3//! `my_crate` is a collection of utilities to make performing certain
4//! calculations more convenient.
5
6//! # Art
7//!
8//! A library for modeling artistic concepts.
9
10pub use kinds::PrimaryColor;
11pub use kinds::SecondaryColor;
12pub use utils::mix;
13
14pub mod kinds {
15    /// The primary colors according to the RYB color model.
16    pub enum PrimaryColor {
17        Red,
18        Yellow,
19        Blue,
20    }
21
22    /// The secondary colors according to the RYB color model.
23    pub enum SecondaryColor {
24        Orange,
25        Green,
26        Purple,
27    }
28}
29
30pub mod utils {
31    use kinds::*;
32
33    /// Combines two primary colors in equal amounts to create
34    /// a secondary color.
35    pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
36        SecondaryColor::Green
37    }
38}
39
40/// Adds one to the number given.
41///
42/// # Examples
43///
44/// ```
45/// let five = 5;
46///
47/// assert_eq!(6, my_crate_carllhw::add_one(5));
48/// ```
49pub fn add_one(x: i32) -> i32 {
50    x + 1
51}
52
53#[cfg(test)]
54mod tests {
55    use super::*;
56
57    #[test]
58    fn test_add_one() {
59        assert_eq!(add_one(3), 4);
60    }
61}