publish_crate/
lib.rs

1// Three dashes is a documentation comment (generates HTML documentation)
2// Generate it through cargo doc 
3//! # Publish Create
4//! This is for contained items rather than following items.
5//! Often used for documenting the entire crate or module
6
7
8/// Adds one to the number given.
9///
10/// # Herp
11/// ## Derp
12/// ### hurr
13/// `dope`
14/// # Examples
15///
16/// ```
17/// let arg = 5;
18/// let answer = publish_crate::add_one(arg);
19///
20/// assert_eq!(6, answer);
21/// ```
22
23// cargo test will run examples as tests
24pub fn add_one(x: i32) -> i32 {
25    return x + 1;
26}
27
28
29// re-arranging internal organization by re-exporting items through pub use 
30
31pub use self::kinds::PrimaryColor; // this does so the user only have to write "use publish_crate::PrimaryColor"
32									//rather than specify the internal module
33pub use self::kinds::SecondaryColor;
34pub use self::utils::mix;
35
36pub mod kinds {
37    /// The primary colors according to the RYB color model.
38    pub enum PrimaryColor {
39        Red,
40        Yellow,
41        Blue,
42    }
43
44    /// The secondary colors according to the RYB color model.
45    pub enum SecondaryColor {
46        Orange,
47        Green,
48        Purple,
49    }
50}
51
52pub mod utils {
53    use crate::kinds::*;
54
55    /// Combines two primary colors in equal amounts to create
56    /// a secondary color.
57    pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
58        // --snip--
59        SecondaryColor::Orange
60    }
61}