Both bin and lib in the one crate

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):

Cargo.toml configuration

Here is a specification in the Cargo.toml file.

// Cargo.toml
name = "nexssp_os_lib"
path = "src/"

name = "nexssp-os"
path = "src/"

Library file

// src/
pub fn example_function() {
    println!("Function from lib!");

Usage of the library

use nexssp_os_lib::example_function; // here is an import of the library
fn main() {
    println!("Hello, world!");
If you found it valuable, please join to the supporters at: Support