Compile and run a Rust program using Cargo

Pascal Precht
InstructorPascal Precht
Share this video with your friends

Social Share Links

Send Tweet

In this lesson we'll learn how to use the cargo run command to compile and run a Rust program.

Instructor: [00:00] We can compile a Rust project using Cargo and its built commands. This will create a target directory in which we can find the executable of our program. From here, we can again run our program on the command line.

[00:20] A more convenient way to compile and run our Rust program is to use Cargo's run command. This one will compile and execute the program in one go. Cargo also comes with a clean command to remove the generated target. Once executed, we can see that the target directory has been removed from the project.