hyeonbungi_rust_playground/
lib.rs1pub fn add_one(x: i32) -> i32 {
16 x + 1
17}
18
19pub use self::kinds::PrimaryColor;
20pub use self::kinds::SecondaryColor;
21pub use self::utils::mix;
22
23pub mod kinds {
24 #[derive(PartialEq)]
26 pub enum PrimaryColor {
27 Red,
28 Yellow,
29 Blue,
30 }
31
32 pub enum SecondaryColor {
34 Orange,
35 Green,
36 Purple,
37 }
38}
39
40pub mod utils {
41 use crate::kinds::*;
42
43 pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
45 if (c1 == PrimaryColor::Red && c2 == PrimaryColor::Yellow)
46 || (c1 == PrimaryColor::Yellow && c2 == PrimaryColor::Red)
47 {
48 SecondaryColor::Orange
49 } else if (c1 == PrimaryColor::Red && c2 == PrimaryColor::Blue)
50 || (c1 == PrimaryColor::Blue && c2 == PrimaryColor::Red)
51 {
52 SecondaryColor::Purple
53 } else {
54 SecondaryColor::Green
55 }
56 }
57}