'unused' warning in a library module

I have dozens of "unused" warning in my src/lib, which is surprising, as I specifically indicated this my "library" module. I have searched on internet to see if I have somehow incorrect project structure, but it doesn't seem like it:

- root
  - src
    - lib
      - mod.rs
      - types.rs
- Cargo.toml

Unused code in a binary, indeed, deserves a warning, but in a library? By definition a library will contain ''unused'' code.

What's the recommended way to deal with all these warnings? spray #!allow(unused) on every declaration?

I guess these warnings are on code which is not only not used by the library itself, but also not exported, i.e. can't be used when this library is added as a dependency.

1 Like

OH. okey i need to pub it explicitely. Understood, solved!

By the way, it looks like you have done something strange with your file layout. Normally the root file of a library crate (that Cargo will automatically use) is src/lib.rs, not src/lib/mod.rs. It is unidiomatic to change that default if you don't have to.

1 Like

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.