I made a summary of all the file name conventions that cargo recognizes:
Blue are names of your choosing, black names must be used verbatim.
I made a summary of all the file name conventions that cargo recognizes:
Blue are names of your choosing, black names must be used verbatim.
Cool.
I'm wondering how src/lib
fits in to all this? I notice you don't have it there.
Sometimes I have had the compiler complaint can't find some file and suggesting I create a src/lib/whatever.rs
for it.
On one occasion I got mightily confused when no matter what I did the compiler refused to see my file. Then I discovered that in some experiment I had put mod lib;
in a source file. Removing that fixed it.
I don't think src/lib
has any special meaning.
Here's a likely scenario:
You created a file src/lib/mod.rs
. You (not cargo) made the choice to call the directory "lib". As you just said, in your top level crate you wrote mod lib
. Then in your src/lib/mod.rs
you wrote mod whatever
. Then the compiler will say:
error[E0583]: file not found for module `whatever`
--> src\lib\mod.rs:1:1
|
1 | mod whatever;
| ^^^^^^^^^^^^^
|
= help: to create the module `whatever`, create file "src\lib\whatever.rs"
If you did that, it would simply be a module that you can access with use lib::whatever::*
.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.