Rust Book, Chapter 1 Flashcards
Review concepts of the Rust programming language
How to check if rust is installed and Which version you have?
Run the following script on the shell:
rustc – version
How to update Rust version?
Run the following script on the shell:
rustup update
How to uninstall Rust?
rustup self uninstall
How to acesso local Rust documentation
rustup doc
What is the convention on file naming?
Lowercase separating words with “_”
In the following com and, What does it mean the “!”?
println!(“Hello, world!”);
It means you are calling a macro and not a function
What does the following command do?
$ rustc main.rs
It call the Rust compiler to compile a file named main.rs
What is the Rust build system and package manager?
cargo
How do you check cargo version
cargo –version
How to create a new project with cargo?
cargo new xxx
How the .toml file is structured and what his function?
.toml (Tom’s Obvious, Minimal Language) file has 2 main sections:
[package] - is a section heading that indicates the configuration information Cargo needs to compile your program;
[dependencies] - where you list any of your project’s dependencies
What does the following command do?
cargo build
This command creates an executable file in target/debug/xxx
You can later execute it via “.\target\debug\xxx.exe”
What does the “cargo run” command do?
It compile the code and then run the resultant executable all in one command
What does the “cargo check” command do?
This command quickly checks your code to make sure it compiles but doesn’t produce an executable
When do you use “cargo build –release”, what does it differ from the usual command?
When you want to build the final program you’ll give to a user that won’t be rebuilt repeatedly and that will run as fast as possible.
This commands tells cargo to compile it with optimizations and generates the executionable in the target/release folder, instead of the debug one.