On some of the online tutorials, folks says that you cannot have bin and lib together, but actually it is possible. Here is the example crate which allows for that (Of course you specify bin and lib):
Here is a specification in the Cargo.toml file.
// Cargo.toml
[lib]
name = "nexssp_os_lib"
path = "src/lib.rs"
[[bin]]
name = "nexssp-os"
path = "src/main.rs"
// src/lib.rs
pub fn example_function() {
println!("Function from lib!");
}
// src.main.rs
use nexssp_os_lib::example_function; // here is an import of the library
fn main() {
println!("Hello, world!");
example_function();
}
If you found it valuable, please join to the nexss.com supporters at: Support Nexss.com