If I create a new cargo "package" with cargo new --lib testlib
I can see that the resulting directory structure contains a src/lib.rs
file.
I am aware that cargo uses the name lib.rs
as a special name with special meaning. In other words, if it sees something called lib.rs
it knows that it should compile the containing source code into a single binary library. This binary library is then available to be linked with other binary executables.
Is it possible to change the name lib.rs
to something else, perhaps by configuring Cargo via the Cargo.toml
file, or otherwise?
Essentially, I would really rather call the library root something like kafkalib.rs
. I am not sure if this is possible.
One alternative workaround which occurred to me would be to declare a module within lib.rs
.
mod kafkalib;
And then either create ./kafkalib/mod.rs
or kafkalib.rs
, and put the associated Kafka library code in this file.
Then, helper code which is not directly related could either be placed in lib.rs
directly, or in some other module adjacent to kafkalib
.
Perhaps this "workaround" is actually the intended use? Since this is all still new to me I can't be sure what the most sensible approach is. The above is really a guess.