#How to `use` a module down one directory

5 messages · Page 1 of 1 (latest)

light fox
#

My current file setup is

src
 |_ bin
   |_ prog.rs
 |_ dep.rs
 |_ main.rs

I'd like for prog.rs to be able to import a function from dep.rs but i haven't seemed to find a way to do that.

spring fox
#

I believe you have to create a lib.rs in src, and declare your module there as well. Things in main.rs will not be available, so move them to lib.rs if you need them in both. Then you'll find them under the name of your project.

fierce flame
#

you should have a lib.rs that has all the shared code (and it can have modules such as mod dep;)

light fox
#

ah cool

fierce flame
#

(if you want code for only prog then that looks like

src/bin/prog/
  dep.rs
  main.rs

but it sounds like you want shared code)