Here is the file tree of my demo project:
.
├── Cargo.lock
├── Cargo.toml
├── src
├── lib.rs
├── ooo.rs
└── xxx.rs
In lib.rs
:
mod xxx;
mod ooo;
In xxx.rs
:
pub fn hello() {
println!("hello!");
}
In ooo.rs
:
use xxx::hello;
pub fn world() {
hello();
println!("world!");
}
When I execute cargo build
, it doesn't succeed:
Compiling ooo v0.1.0 (/Users/eric/ooo)
error[E0432]: unresolved import `xxx`
--> src/ooo.rs:1:5
|
1 | use xxx::hello;
| ^^^ Could not find `xxx` in `{{root}}`
I know that if I use super::ooo::hello
instead of ooo::hello
, it will succeed, but is there any way I can use ooo::hello
and succeed?
For example, this works in the redis-rs
project in src/client.rs
where connection
and types
are the modules in this crate:
use connection::{connect, Connection, ConnectionInfo, ConnectionLike, IntoConnectionInfo};
use types::{RedisFuture, RedisResult, Value};