I have a question about rust modules resolution.
It seems to be that inside crate modules I can reference the other modules using crate name or crate
/super
/self
keywords.
but in main.rs
I can only use modules with crate name?
Am I doing something stupid here?
My project:
$ tree
.
├── Cargo.toml
└── src
├── add2.rs
├── add.rs
├── lib.rs
└── main.rs
Cargo.toml
content:
[package]
name = "example"
....
main.rs
content:
use example::add::{add_one};
fn main() {
println!("{}", add_one(1));
}
lib.rs
content:
pub mod add;
add.rs
content:
pub fn add_one(x: i32) -> i32 {
x + 1
}
add2.rs
content:
use crate::add::{add_one};
pub fn add_two(x: i32) -> i32 {
add_one(add_one(x))
}