To start, we need to create the crate itself.
To do this, instead of writing the following, we need to tell cargo that we are creating a library:
cargo new myapp -bin
To do this, we simply omit the -bin flag:
cargo new MathLib
The following screenshot shows this, followed by the tree structure for the module. You'll notice that main.rs has been replaced by lib.rs:
Figure 1