Reputation: 651
I have 2 files: lib.rs and user.rs
user.rs:
struct User { .... }
and lib.rs:
use User; // unresolved import `User`
Whatever I tried it hasn't panned out, for example:
use self::User; // unresolved import `User`
use super::User;
Upvotes: 3
Views: 5302
Reputation: 127721
You need to declare the user
module in lib.rs
first, and then import the structure from it:
mod user;
use user::User;
It is important that user
in mod user
coincide with user
in user.rs
file name.
Rust module system can be confusing for novices in the language; you really should read the official documentation on this.
Upvotes: 12