learning_rust/lib.rs
1//! # learning_rust
2//!
3//! `learning_rust` is 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 = learning_rust::add_one(arg);
13///
14/// assert_eq!(6, answer);
15/// ```
16pub fn add_one(x: i32) -> i32 {
17 x + 1
18}
19
20/// 配置颜色
21///
22/// # Examples
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 /// Combines two primary colors in equal amounts to create
43 /// a secondary color.
44 pub fn mix(c1: PrimaryColor, c2: PrimaryColor)-> SecondaryColor{
45 SecondaryColor::Orange
46 }
47}
48
49pub use self::kinds::PrimaryColor;
50pub use self::kinds::SecondaryColor;
51pub use self::utils::mix;