I have defined some table & struct in src/schema.rs and src/models.
I also wrote some pub fn
inside src/lib.rs.
But I just cannot use those pub fn
s in other rs files so moved into src/io.rs later.
Whatever they're in src/lib.rs or in src/io.rs separately, when calling them by use crate::fn_name
or use crate::io::fn_name
, the compiler would warn me that:
# cargo build
Compiling minstl v0.2.4 (/home/user/minstl)
error[E0433]: failed to resolve: use of undeclared crate or module `libmi`
--> src/http.rs:6:5
|
6 | use libmi::auth::LoginReq;
| ^^^^^ use of undeclared crate or module `libmi`
error[E0412]: cannot find type `LoginReq` in this scope
--> src/http.rs:35:36
|
35 | async fn req_login(data: web::Json<LoginReq>, req: HttpRequest) -> Result<HttpResponse> {
| ^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
1 | use crate::auth::LoginReq;
|
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0412, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `minstl`
To learn more, run the command again with --verbose.
libmi is the name of lib I defined in Cargo.toml.
and it is still unfeasible to use the method recommended in help:
# cargo build
Compiling minstl v0.2.4 (/home/user/minstl)
error[E0432]: unresolved import `crate::auth`
--> src/http.rs:1:12
|
1 | use crate::auth::LoginReq;
| ^^^^
| |
| unresolved import
| help: a similar path exists: `libmi::auth`
error[E0432]: unresolved import `crate::io`
--> src/http.rs:2:12
|
2 | use crate::io::{create_request, establish_connection};
| ^^
| |
| unresolved import
| help: a similar path exists: `libmi::io`
error[E0432]: unresolved import `crate::shell`
--> src/http.rs:3:12
|
3 | use crate::shell::StmtReq;
| ^^^^^
| |
| unresolved import
| help: a similar path exists: `libmi::shell`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0432`.
error: could not compile `minstl`
To learn more, run the command again with --verbose.
code is here:
https://github.com/halldong/minstl/blob/main/src/http.rs#L1-L3
I'm so confused. Is there anyone can help?