External dependencies

Normally, if a dependency is outside the application, we would add something like this to the Cargo.toml file:

[dependencies] 
mathslib = "0.1.0" 

In this case, we're not able to use cargo to make the build; instead, we need to compile using rustc. The way cargo works is it recompiles the dependencies for each project (there is no guarantee that each project will use the same set of features for a given crate).

We can simulate a cargo run with the following command:

rustc -L . src/main.rs && ./main 

The -L links any libraries in . (the root directory, where you find Cargo.toml) to the sources after the . . The /main part essentially tells the command-line interpreter to execute the binary called ./main in the root directory (the name comes from the file compiled).

Once we have executed this, we can see our application in all its glory:

Figure 8

We now know that our crate (as-is) is running as it should do.

..................Content has been hidden....................

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