Getting Started Flashcards

(38 cards)

1
Q

Which tool is recommended for installing and managing Rust versions?

A

rustup, a command-line installer and version manager for Rust toolchains.

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

Why does the book tell you to install the stable toolchain?

A

Rust’s stability guarantees mean examples written for today’s stable compiler will keep compiling with future stable releases.

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

Why might you need a C compiler after installing Rust?

A

Rust links final binaries and many crates include C code; a C tool-chain provides the linker.

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

How do you confirm Rust is installed correctly?

A

Run rustc –version; you should see rustc x.y.z (commit-hash yyyy-mm-dd).

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

Single command to keep Rust up to date?

A

rustup update downloads and installs the newest stable toolchain.

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

If you don’t want to use rustup, where should you look?

A

The Other Rust Installation Methods page linked near the top of the guide.

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

What shorthand nickname do Rust developers use for themselves?

A

Rustaceans—you’ll see the term on the community sites.

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

What is the mandatory entry-point function that every executable Rust program must define?

A

main (it’s the first code that runs).

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

Where are a function’s body and its statements placed in Rust?

A

Inside { } curly braces following the function header.

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

What file-name extension must every Rust source file use?

A

.rs

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

When a filename contains multiple words, what delimiter is conventional in Rust?

A

An underscore, e.g., hello_world.rs (not helloworld.rs).

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

Which command compiles a single Rust source file?

A

rustc <filename>.rs (e.g., rustc main.rs).</filename>

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

Which Rust construct prints text to the terminal in the “Hello, world!” example?

A

The macro println!(“Hello, world!”);.

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

How can you visually distinguish a macro call from a function call in Rust?

A

A macro ends with an exclamation mark (!), e.g., println!.

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

What punctuation ends most Rust statements and expressions?

A

A semicolon (;).

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

Why is Rust described as an “ahead-of-time compiled” language?

A

You compile to a standalone binary that can run on a machine without Rust installed.

17
Q

Compared with dynamic languages like Python or JavaScript, what extra step does Rust require before execution?

A

An explicit compilation step separate from running the program.

18
Q

What automatic formatting tool ships with the standard Rust distribution?

19
Q

Which language-server/IDE helper is the Rust team focusing on?

A

rust-analyzer

20
Q

Why might you separate compiling and running when your Rust project grows?

A

To manage many build options and dependencies more easily (leading to the introduction of Cargo).

21
Q

What is Cargo?

A

Cargo is Rust’s build system and package manager; it builds your code, fetches dependencies (called crates), and builds those crates too.

22
Q

How do you verify that Cargo is installed?

A

Run cargo –version in your terminal; a version string indicates success.

23
Q

Which command creates a brand-new Cargo project?

A

cargo new project_name (e.g., cargo new hello_cargo).

24
Q

What three items does cargo new generate?

A

A Cargo.toml file, a src directory containing main.rs, and (by default) an initialized Git repository with .gitignore.

25
Where does Cargo expect your source code to live?
Inside the src directory of the project; the top-level folder is reserved for docs, configs, etc.
26
What is the purpose of the [dependencies] section in Cargo.toml?
It lists external crates your project relies on; Cargo downloads and manages them automatically.
27
Which command compiles your project in debug mode?
cargo build — it outputs the binary to target/debug/.
28
How do you compile and run in one step?
Use cargo run; it builds (if needed) and then executes the binary.
29
Which command quickly verifies compilation without creating a binary?
cargo check, ideal for rapid syntax/borrow checking while you code.
30
What file does Cargo create on first build to pin exact dependency versions?
Cargo.lock; Cargo maintains it automatically.
31
How can you convert a manual Rust project into a Cargo project?
Move code into src/ and run cargo init to generate a suitable Cargo.toml.
32
Which command produces an optimized release binary? Where is it placed?
cargo build --release; the binary lands in target/release/.
33
Why are there separate debug and release profiles?
Debug builds compile quickly with debug info; release builds take longer but run faster thanks to optimizations.
34
What advantage does Cargo give across different operating systems?
The same Cargo commands work on Linux, macOS, and Windows, so you don’t memorize platform-specific toolchains.
35
How can you change the VCS behavior when creating a project?
Add --vcs (e.g., cargo new myapp --vcs=git or --vcs=none).
36
In Rust terminology, what is a crate?
A package of Rust code that can be compiled or depended upon; your package may contain one (or more) crates.
37
Why is using Cargo preferable once a program spans multiple files or uses dependencies?
Cargo orchestrates compilation order and dependency fetching automatically, saving manual rustc invocations.
38
List the 4 most-common day-to-day Cargo commands.
cargo new, cargo build, cargo run, cargo check — they cover project creation, compilation, execution, and rapid checking.