rust_cheatsheet/
lib.rs

1// Documenting library code
2
3//! # Art
4//! A library for modeling artistic concepts
5
6pub mod theory {
7	//! # Theory Module
8	//! `theory` is a collection of basic mathematical
9	//! utility functions 
10
11	/// Adds one to the number given
12	/// # Example
13	/// ```
14	/// use rust_cheatsheet::theory;
15	/// let x = 1;
16	/// let y = theory::add_one(x);
17	/// assert_eq!(y, x + 1);
18	/// ```
19	pub fn add_one(x: i32) -> i32 {
20		x + 1
21	}
22
23	/// Adds two to the number given
24	/// ```
25	/// use rust_cheatsheet::theory;
26	/// let x = 1;
27	/// let y = theory::add_two(x);
28	/// assert_eq!(y, x + 2);
29	/// ```
30	pub fn add_two(x: i32) -> i32 {
31		x + 2
32	}
33
34	pub mod internal {
35		//! # Internal Module
36		//! mod `internal` specifies some more
37		//! internal functionality
38
39
40		/// this function pretty much does nothing
41		/// important
42		/// # Example
43		/// ```
44		/// use rust_cheatsheet::theory::internal;
45		/// internal::check_addition();
46		/// ```
47		pub fn check_addition() {
48			// does nothing
49		}
50		
51	}
52
53}
54
55pub mod base {
56	//! base module
57
58	/// vrooom!!!!!!!!
59	/// # Example
60	/// ```
61	/// use rust_cheatsheet::base;
62	/// base::start();
63	/// ```
64	pub fn start() {}
65}
66
67pub use self::kinds::PrimaryColor;
68pub use self::kinds::SecondaryColor;
69pub use self::utils::mix;
70
71pub mod kinds {
72	//! kinds of colors
73
74	// the primary colors according to RYB color model
75	pub enum PrimaryColor {
76		Red, Yellow, Blue
77	}
78	// the secondary colors according to RYB color model
79	pub enum SecondaryColor { Orange, Green, Purple }
80}
81
82pub mod utils {
83    use crate::kinds::{PrimaryColor, SecondaryColor};
84
85	/// Combines two primary colors in equal ammounts to create
86	/// a secondary color.
87	pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
88		// --snip--
89		// ANCHOR_END: here
90		SecondaryColor::Orange
91		// ANCHOR: here
92	}
93}