Files
mist-website/content/docs/guide/modules.mdx
T
2026-07-03 10:23:45 +02:00

30 lines
820 B
Plaintext

---
title: Modules & Imports
description: Module declarations, imports, re-exports, and module resolution rules.
icon: FolderTree
---
```mist
// Declare a submodule
pub module foo;
// Import
use std::collections::HashMap;
// Re-exporting import
pub use my_module::MyType;
```
### Module Resolution
Mist maps the module tree to Rust's module system:
| Mist Path | Rust Output |
|------------------------------|------------------------------|
| `src/main.mist` | `.mist/src/main.rs` |
| `src/utils/package.mist` | `.mist/src/utils/mod.rs` |
| `src/foo.mist` | `.mist/src/foo.rs` |
| `src/utils/helper.mist` | `.mist/src/utils/helper.rs` |
A `package.mist` file acts as a directory's module root, analogous to `mod.rs`.