To create an internal (private) module in Rust, define the module without the pub keyword and keep its items private by omitting pub from them.
mod internal_utils {
fn helper() {
// This function is only accessible within this module
}
pub fn public_helper() {
// This is accessible outside the module
}
}
// internal_utils::helper() would fail here
internal_utils::public_helper(); // This works
By default, modules and their contents are private to the parent module unless explicitly marked pub.