I have two files :
- json.rs in which I call Builder, a struct defined in builder.rs
- builder.rs in which I call Json, a struct defined in json.rs
As you can see there is a circular dependency between these two modules. It seems like sometimes Rust supports circular dependencies, but for this case, the compiler throws errors:
src/json/mod.rs:1:25: 1:31 error: unresolved import (maybe you meant `ToJson::*`?)
src/json/mod.rs:1 pub use self::to_json::{ToJson};
^~~~~~
src/json/builder.rs:2:18: 2:22 error: unresolved import (maybe you meant `Json::*`?)
src/json/builder.rs:2 use json::json::{Json, JsonEvent, Array, Object}; //commenting this line solve the dependency error
[...]
The code is here in the branch json_mod. I tried to reproduce the problem in fewer lines of code, but the circular dependencies I created compiled correctly.
After the debugging, something like 400 errors are left — this is normal as I am in the process of a huge code refactoring (splitting one file of ~= 4000 line file into many files) and I still have a lot of work to do before making it work.