Reputation: 936
I'm writing a Rust library called my_new_lib
and have the following file structure:
├── my_new_lib
├── src
├── lib.rs
└── file1.rs
├── tests
In lib.rs
I defined a struct:
/// content of lib.rs
pub struct my_struct {}
In file1.rs
I want to use my_struct
, for example:
/// content of file1.rs
use ????
pub struct my_second_struct {
member1: my_struct
}
what should I put in the use
clause in file1.rs
to make it work?
Upvotes: 0
Views: 412
Reputation: 42849
You must use the crate
keyword to access to the root of your crate:
use crate::MyStruct;
Upvotes: 1