Skip to content

Modules

Modules let you split code across files and reuse definitions from other files.

To import another file in the same project, use import with the module name.

import data;

You can also import everything from a module.

import * from data;
import * from std::option;
// The super keyword can be used to reference the parent module
import * from super;

If you only want one item, import it by name.

import File from std::fs;
import Channel from std::async;

Or if you want multiple specific items, use brackets.

import (Channel, WaitGroup) from std::async;

Once imported, you can use the types, functions, and constants exposed by that module in the current file as if they were defined in that file.