I am using Rust 2018 with the following file structure:
src/main.rs
src/types.rs
src/compute.rs
types.rs
contains pub struct Entity {}
.
I have no issue including types
and compute
in main.rs
:
mod types;
mod compute;
I want to import types
inside compute.rs
:
mod types;
// or
pub mod types;
I get:
file not found for module types
I tried to follow path clarity in the edition guide without success.
The examples never refer to a same level import that is not from main.rs
or lib.rs
I tried to specify the path using:
#[path = "types.rs"] mod types;
Then I get this error:
expected type `compute::types::Entity`
found type `types::Entity`
It seems it is redefining the module types
inside my module compute
.
I cannot use the use
keyword since it is not an external crate.
I took a look at file hierarchy in Rust by Example but there is no same level import.
I am trying to avoid having mod.rs
like in Rust 2015.
Is there a way to do this same level import?
Is my file structure the issue?
What file structure would be better?