rust_lab_1/
lib.rs

1//! # Rust-Lab
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/// # Panics
9/// # Safety
10/// # Examples
11///
12/// ```
13/// let arg = 5;
14/// let answer = rust_lab::add_one(arg);
15///
16/// assert_eq!(6, answer);
17/// ```
18pub fn add_one(x: i32) -> i32 {
19    x + 1
20}
21/// Adds one to the number given.
22///
23/// # Panics
24/// # Safety
25/// # Examples
26///
27/// ```
28/// let arg = 5;
29/// let answer = rust_lab::add_two(arg);
30///
31/// assert_eq!(7, answer);
32/// ```
33pub fn add_two(a: i32) -> i32 {
34    internal_adder(a, 2)
35}
36/// Adds one to the number given.
37///
38/// # Panics
39/// # Safety
40/// # Examples
41///
42/// ```
43/// let arg_1 = 5;
44/// let arg_2 = 5;
45/// let answer = rust_lab::internal_adder(arg_1,arg_2);
46///
47/// assert_eq!(10, answer);
48///
49pub fn internal_adder(a: i32, b: i32) -> i32 {
50    a + b
51}
52
53#[cfg(test)]
54mod tests {
55    use super::*;
56
57    #[test]
58    fn internal() {
59        assert_eq!(4, internal_adder(2, 2));
60    }
61}
62
63pub use self::kinds::PrimaryColor;
64pub use self::kinds::SecondaryColor;
65pub use self::utils::mix;
66
67pub mod kinds {
68    /// The primary colors according to the RYB color model.
69    pub enum PrimaryColor {
70        Red,
71        Yellow,
72        Blue,
73    }
74
75    /// The secondary colors according to the RYB color model.
76    pub enum SecondaryColor {
77        Orange,
78        Green,
79        Purple,
80    }
81}
82
83pub mod utils {
84    use crate::kinds::*;
85
86    /// Combines two primary colors in equal amounts to create
87    /// a secondary color.
88    pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
89        SecondaryColor::Orange
90    }
91}