How to Create Modules in Rust with mod

Create Rust modules using the `mod` keyword and separate files to organize code and control visibility with `pub`.

Create a module by declaring mod module_name; in your source file and placing the code in a file named module_name.rs or a directory named module_name containing a mod.rs file. Use pub to make items inside the module accessible from outside.

// src/lib.rs
pub mod kinds {
    pub enum PrimaryColor {
        Red,
        Yellow,
        Blue,
    }
}

pub mod utils {
    use crate::kinds::*;

    pub fn mix(c1: PrimaryColor, c2: PrimaryColor) {
        // Implementation here
    }
}

// src/kinds.rs (if using separate file) pub enum PrimaryColor { Red, Yellow, Blue, }

// src/utils.rs (if using separate file) use crate::kinds::*;

pub fn mix(c1: PrimaryColor, c2: PrimaryColor) { // Implementation here }