chap16_my_crate/
lib.rs

1
2
3/* para entrar en la documentacion de tus programas creados:
4	 cargo doc --open
5*/
6
7// el simbolo //! #  va el titulo en la documentacion luego //! va escritos esn la documentacion
8
9//! # chap16 My Crate
10//!
11//! `chap16_my_crate` is a cellection of utilities to make performing certain
12//! calculation more convenient.
13
14//! # Art 
15//! 
16//! A library for modeling artistic concepts
17
18/// Adds one to the number given
19/// 
20/// # Examples
21/// 
22/// ```
23/// let arg = 5;
24/// let answer = chap16_my_crate::add_one(arg);
25///
26/// assert_eq!(6, answer);
27/// ```
28
29pub fn add_one(x: i32) -> i32 {
30	x + 1
31}
32
33// con esto ya no necesita en el main.rs poner el path completo
34pub use self::kinds::PrimaryColor;
35pub use self::kinds::SecondaryColor;
36pub use self::utils::mix;
37
38pub mod kinds {
39	/// The primary colors according to the RYB color model.
40	pub enum PrimaryColor {
41	    Red,
42	    Yellow,
43	    Blue,
44	}
45
46	/// The secondary colors according to the RYB color model.
47	pub enum SecondaryColor {
48		Orange,
49		Green,
50		Purple,
51
52	}
53
54}
55
56pub mod utils {
57	use crate::kinds::*;
58	/// Combines two primary colors in equal amounts to create
59	/// a secondary color.
60	pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
61		// --snip--
62		// ANCHOR_END: here
63		SecondaryColor::Orange
64		// ANCHOR: here
65	}
66}