Getting Started Flashcards
Does Rust require a Linker installed on your system?
Yes. C compilers usually come with the correct linker. Also, some common Rust packages depend on C code and will need a C compiler
What is the command to update rust to the latest stable version?
rustup update stable
Rustup installs local documentation. What is the command to open it?
rustup doc
This will open the documentation in your browser.
What is the extension for Rust files?
*.rs
By convention, Rust filenames use snake case with underscores between words.
What function runs first when a Rust program is executed?
main(), though there is a small Rust “runtime” which runs before this, then calls main() as the first function to execute. The body of main() must be surrounded by curly braces.
What is the tool to format Rust code in the established style?
rustfmt
Does Rust indent code with tabs or spaces?
The Rust convention is to indent with 4 spaces.
What is println!() an example of?
A macro.
What character ends an expression?
The semicolon (;) character indicates that an expression is over and the next one is ready to begin.
How do you compile a Rust file using the Rust compiler?
Enter: rustc file_name.rs
What is the output of the Rust compiler?
A binary executable.
Rust is an ahead-of-time compiled language. What does this mean?
You can compile an executable and give it to someone else, and they can run it without having Rust installed.
What is Rust’s build system and package manager called?
Cargo
What is the name for libraries your code needs?
Dependencies
What does the command “cargo new hello_world” do?
It initialises a new Rust executable package. It will create a directory called “hello_world”. In this directory it will create a Cargo.toml file and a src directory containing the file main.rs. It will also create a .gitignore file unless the –vcs switch is used to use another VCS or none at all.