Modules and Code Organization
In this chapter, we'll explore organize your code with mana's module system.
Modules and Code Organization
As you write larger programs, organizing your code becomes increasingly important. Mana's module system helps you group related functionality, control visibility, and manage code across multiple files.
In this chapter, we'll cover:
- Module Declarations — How modules work in Mana
- Visibility and Privacy — Control access with
pub - Imports and Paths — Bring items into scope with
use - Multi-File Projects — Organize code across files
The Module Declaration
Every Mana file begins with a module declaration:
module main
fn main() -> void {
println("Hello, world!")
}The module statement declares what module this file belongs to. This is required at the top of every .mana file.
Let's start with Module Declarations.