Calling a second module from a first module (not from main)

    1. I have create a new project with cargo.
    1. I the src/ folder, I have a file.
    1. I have added an file and I can refer it in as m1 (imported with : "mod m1").

My question is : how can I do the same for m1: i.e. create an file which I can import as m1 into m2 and refer to as m1?

Simply trying to import m2 into m1 as if m1 was does not seem to work.

Ops !
Just found out.
"mod m2" goes into as well as "mod m1" (and not into, oddly).

mod works exactly like struct, enum, and fn. It creates a new named thing in the file where you write it.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.