1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! # cargo_more
//!
//! `cargo_more` is a collection of utilities to make performing certain
//! calculations more convenient. 这种文档是用来描述整个 crate 的文档。一般放在lib.rs 或 main.rs

pub mod kinds;
pub mod utils;

// 重导出一些层级较深的结构,使得用户可以更快的找到和使用他们
pub use self::kinds::PrimaryColor;
pub use self::kinds::SecondaryColor;
pub use self::utils::mix;

/// Adds one to the number given
///
/// # Examples
///
/// ```
/// // cargo test 连示例程序也会测试运行
/// let arg = 5;
/// let answer = tomoko_cargo_more::add_one(arg);
///
/// assert_eq!(6, answer);
/// ```
///
/// # Panics
/// This function might panic if the x is not i32 value
pub fn add_one(x: i32) -> i32 {
    x + 1
}

/// Add two to the number given
///
/// # Examples
///
/// ```
/// let arg = 1;
/// let answer = tomoko_cargo_more::add_two(arg);
///
/// assert_eq!(answer, 3);
/// ```
pub fn add_two(x: i32) -> i32 {
    x + 2
}