How to use structures from sibling/adjacent rust file?

Viewed 92

I'm trying to edit a Rust project with the following structure:

src/iface/ip.rs

src/iface/tun.rs

I want to call things from ip.rs inside tun.rs. So on tun.rs I added:

use iface::ip;

but it says

unresolved import `iface::ip`

no `ip` in `iface`rustc(E0432)

This seems to be the way to do it as explained here https://stackoverflow.com/a/30687811/6655884 and here https://stackoverflow.com/a/26390046/6655884

I also tried mod ip but it didn't work either.

1 Answers

In iface/mod.rs

pub mod ip;

In iface/tun.rs

use crate::iface::ip;

Related