noir by example


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`

    // otherwise, include the full path

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

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

fn test_main() {

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

prev (nested modules) next (higher order functions)