1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-16 05:38:54 +02:00
comprehensive-rust/src/modules.md
2022-12-21 16:38:28 +01:00

396 B

Modules

We have seen how impl blocks lets us namespace functions to a type.

Similarly, mod lets us namespace types and functions:

mod foo {
    pub fn do_something() {
        println!("In the foo module");
    }
}

mod bar {
    pub fn do_something() {
        println!("In the bar module");
    }
}

fn main() {
    foo::do_something();
    bar::do_something();
}