Rust Book, Chapter 1 Flashcards

Review concepts of the Rust programming language

1
Q

How to check if rust is installed and Which version you have?

A

Run the following script on the shell:
rustc – version

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to update Rust version?

A

Run the following script on the shell:
rustup update

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to uninstall Rust?

A

rustup self uninstall

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to acesso local Rust documentation

A

rustup doc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the convention on file naming?

A

Lowercase separating words with “_”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In the following com and, What does it mean the “!”?
println!(“Hello, world!”);

A

It means you are calling a macro and not a function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the following command do?
$ rustc main.rs

A

It call the Rust compiler to compile a file named main.rs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the Rust build system and package manager?

A

cargo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you check cargo version

A

cargo –version

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to create a new project with cargo?

A

cargo new xxx

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How the .toml file is structured and what his function?

A

.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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the following command do?
cargo build

A

This command creates an executable file in target/debug/xxx
You can later execute it via “.\target\debug\xxx.exe”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the “cargo run” command do?

A

It compile the code and then run the resultant executable all in one command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the “cargo check” command do?

A

This command quickly checks your code to make sure it compiles but doesn’t produce an executable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

When do you use “cargo build –release”, what does it differ from the usual command?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly