rust_samples/
lib.rs

1//!# Art
2//!
3//!一个用来建模艺术概念的代码库
4pub use self::kinds::PrimaryColor;
5pub use self::kinds::SecondaryColor;
6pub use self::utils::mix;
7
8pub mod kinds {
9    use core::fmt;
10    use std::fmt::Formatter;
11
12    // RGB颜色模型
13    pub enum PrimaryColor {
14        Red,
15        Yellow,
16        Blue,
17    }
18
19    // RGB模型的调和色
20    pub enum SecondaryColor {
21        Orange,
22        Green,
23        Purple,
24    }
25}
26
27pub mod utils {
28    use crate::kinds::*;
29
30    /// 将两种等量的颜色混合
31    pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
32        SecondaryColor::Green
33    }
34}