Skip to main content

art_tutorial/
lib.rs

1//! # Art
2//!
3//! A library for modeling artistic concepts.
4
5// pub use 将模块的内容引入到当前作用域中
6// 可以在当前模块中直接使用 PrimaryColor 和 SecondaryColor 枚举
7// 即在main.rs中可以直接使用art::PrimaryColor和art::mix
8pub use self::kinds::PrimaryColor;
9pub use self::kinds::SecondaryColor;
10pub use self::utils::mix;
11
12pub mod kinds {
13    /// The primary colors according to the RYB color model.
14    pub enum PrimaryColor {
15        Red,
16        Yellow,
17        Blue,
18    }
19
20    /// The secondary colors according to the RYB color model.
21    pub enum SecondaryColor {
22        Orange,
23        Green,
24        Purple,
25    }
26}
27
28pub mod utils {
29    use crate::kinds::*;
30
31    /// Combines two primary colors in equal amounts to create
32    /// a secondary color.
33    // 2 个用法
34    #[allow(unused)]
35    pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
36        // --snip--
37        unimplemented!();
38    }
39}