Let's create!

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
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset