noir by example

submodules

not to be confused with nested modules, a submodule has in-line implementation

use mysubmodule::foo;

fn main() {
    // call it directly if imported with `use`
    foo();

    // otherwise, include the full path
    mysubmodule::bar();
}

mod mysubmodule {
    use dep::std; // <-- imports can be scoped to a submodule

    fn foo() { std::println("foo") }
    fn bar() { std::println("bar") }
}

#[test]
fn test_main() {
    main();
}

try it out install the noir toolchain if you haven't yet:
        curl -L https://noirup.org/install | bash
        noirup --nightly
        
then checkout and run the example:
        git clone https://github.com/sambarnes/noir-by-example.git
        cd noir-by-example/circuits/examples/modules-submodules
        nargo test --show-output
        

prev (nested modules) next (higher order functions)