2/5
## Setting Up Your Rust Crash Course Environment Welcome to the Rust Crash Course! This lesson will guide you through the initial setup required to follow along with the course material and successfully complete the exercises. We'll cover cloning the necessary code repository and configuring your development environment. ### Cloning the GitHub Repository The first step is to get the course materials onto your local machine. All exercises, solutions, and examples are hosted in a GitHub repository. 1. **Navigate to the Repository:** Open your web browser and go to `github.com/cyfrin/rust-crash-course`. 2. **Copy the Clone URL:** On the repository page, click the green "Code" button. You'll see options to clone via HTTPS, SSH, or GitHub CLI. The video demonstration uses SSH, but you can choose HTTPS if you're more comfortable with it or haven't set up SSH keys with GitHub. * Select the "SSH" tab (if using SSH) and copy the provided URL (e.g., `git@github.com:Cyfrin/rust-crash-course.git`). * Alternatively, select the "HTTPS" tab and copy that URL. 3. **Clone the Repository Locally:** Open your terminal or command prompt. Navigate to the directory where you want to store the course files. Then, execute the `git clone` command followed by the URL you copied: ```bash git clone git@github.com:Cyfrin/rust-crash-course.git ``` Or, if using HTTPS: ```bash git clone https://github.com/Cyfrin/rust-crash-course.git ``` This command will download the `rust-crash-course` repository into a new folder of the same name in your current directory. ### Development Environment: VS Code and `rust-analyzer` While you can use any text editor or IDE, this course will use Visual Studio Code (VS Code) for demonstrations. For an optimal Rust development experience in VS Code, we highly recommend installing the `rust-analyzer` extension. * **Benefits of `rust-analyzer`:** This extension provides powerful features such as intelligent code completion, real-time error checking, syntax highlighting, go-to-definition, and refactoring tools, significantly enhancing productivity. * **Installing `rust-analyzer` in VS Code:** 1. Open VS Code. 2. Navigate to the Extensions view by clicking the Extensions icon in the Activity Bar on the side of the window (or press `Ctrl+Shift+X`). 3. In the search bar, type "rust-analyzer". 4. Locate the "rust-analyzer" extension published by "The Rust Programming Language". 5. Click the "Install" button. (If it's already installed, this button may show "Uninstall" or a gear icon for settings). Although VS Code and `rust-analyzer` are recommended for the best learning experience, they are not strictly mandatory to follow the course content. ### A Note on Rust Installation Please be aware that this setup lesson does *not* cover the installation of the Rust programming language itself. The process for installing Rust, including `rustc` (the Rust compiler) and `cargo` (the Rust package manager and build tool), will be detailed in the next video lesson of this course. ## Navigating the Course and Completing Exercises Once you've cloned the `rust-crash-course` repository, you'll find a structured environment designed to guide you through various Rust concepts. ### The Main `README.md`: Your Course Map At the root of the cloned `rust-crash-course` directory, you'll find a `README.md` file. This file serves as the main table of contents for the entire course. It lists all the topics covered, including: * Data types (scalar types, tuple, array, String, enum, struct, vector, hash map) * Control flow * Ownership * And many other fundamental Rust concepts. Each topic listed in this `README.md` is a hyperlink that will navigate you to the specific folder dedicated to that topic within the repository. ### Understanding Topic Folders When you click on a topic link in the main `README.md` (for example, "Scalar types"), you will be directed to a corresponding folder, typically structured as `topics/<topic_name>/` (e.g., `topics/scalar/`). Inside each topic folder, you will consistently find two primary subfolders: * **`exercises`**: This folder contains the Rust project files where you will write your code to complete the exercises for that topic. * **`solutions`**: This folder contains the completed solutions for all exercises in that topic. You can refer to these if you get stuck or want to compare your approach. The file structure within the `exercises` and `solutions` subfolders is generally identical to maintain consistency. ### Exercise Instructions: The Topic-Specific `README.md` Within each topic's `exercises` folder (e.g., `topics/scalar/exercises/`), there is another `README.md` file. This nested `README.md` provides detailed instructions specific to the exercises for that particular topic. It will typically include: * An explanation of any example code provided for the topic. * Clear instructions on what tasks need to be completed for each exercise. * How to run any example code snippets. For instance, the `README.md` in `topics/scalar/exercises/` might contain an instruction like: > "Exercise 1: Fix the function `eq` inside `src/lib.rs`. Compare 2 inputs of the type `char` for equality and return a `bool`." ### Writing Your Code: The `src/lib.rs` File The actual Rust code you'll be writing for the exercises is usually located in a file named `lib.rs` inside the `src` directory within a topic's `exercises` folder (e.g., `topics/scalar/exercises/src/lib.rs`). ### The `todo!()` Macro: Your Starting Point When you open an exercise file (like `topics/scalar/exercises/src/lib.rs`), you will find function skeletons that use the `todo!()` macro as their body: ```rust // Example from an exercise file pub fn eq() { todo!(); // Your implementation goes here } pub fn add() { todo!(); // Your implementation goes here } // ... and other functions ``` The `todo!()` macro is a special Rust construct. It's a placeholder that allows the Rust project to compile successfully even if a function's logic hasn't been implemented yet. If a function containing `todo!()` is called at runtime, the program will panic (i.e., crash) with a message indicating that the functionality is not yet implemented. **To complete an exercise:** You need to replace the `todo!()` macro within the specified function(s) with your Rust code that correctly implements the required logic. ### Accessing Solutions If you encounter difficulties with an exercise or wish to verify your implementation, the solutions are readily available. Navigate to the corresponding topic's `solutions` folder, and you'll find the completed code in the `src/lib.rs` file (e.g., `topics/scalar/solutions/src/lib.rs`). The video presenter will typically avoid showing solution files to prevent spoilers during the lessons. ### Following Along with Video Examples The video lessons will often demonstrate Rust concepts using specific code examples. These example files are also included in the repository for your reference. You can find them within the `examples` subfolder inside each topic's `exercises` directory (e.g., `topics/scalar/exercises/examples/`). For instance, the example code demonstrating scalar types might be located in `topics/scalar/exercises/examples/scalar.rs`: ```rust // Example content from topics/scalar/exercises/examples/scalar.rs fn main() { // Scalar types represent a single value // Signed integers // Range: -(2^(n-1)) to 2^(n-1) - 1 let i0: i8 = -1; let i1: i16 = 2; // ... and so on } ``` ### Running Code Examples The `README.md` file within each topic's `exercises` folder (e.g., `topics/scalar/exercises/README.md`) will provide the necessary command to run any associated examples. Look for a section titled "Example" or similar. To run an example using Cargo (Rust's build system and package manager), you'll typically use a command like this from your terminal, ensuring you are in the correct directory (e.g., `topics/scalar/exercises/`): ```bash cargo run --example <example_name> --release ``` For instance, to run the `scalar.rs` example mentioned above, the command would be: ```bash cargo run --example scalar --release ``` This command instructs Cargo to compile and execute the specified example file. The `--release` flag compiles the code with optimizations. ## Additional Learning Resources At the bottom of the main `README.md` file (located in the root directory of the `rust-crash-course` repository), you'll find a "Resources" section. This section contains a curated list of links to valuable external Rust learning materials, such as: * **The Rust Programming Language Book (often called "The Book"):** The official, comprehensive guide to Rust. * **rustlings:** A set of small, interactive exercises to get you used to reading and writing Rust code. * **Rust by Example:** Learn Rust through a series of runnable examples. * **Rust Playground:** An online environment to write, compile, and run Rust code without any local setup. These resources are provided for your further exploration and self-study. They will not be directly used or referenced during the video lessons of this crash course but can significantly deepen your understanding of Rust. ## Next Steps With your environment preparation underway, the next critical step is installing the Rust programming language itself. The subsequent video lesson in this course will provide a detailed walkthrough of the Rust installation process. Be sure to complete that before attempting to compile or run any of the exercises or examples.
Welcome to the Rust Crash Course! This lesson will guide you through the initial setup required to follow along with the course material and successfully complete the exercises. We'll cover cloning the necessary code repository and configuring your development environment.
The first step is to get the course materials onto your local machine. All exercises, solutions, and examples are hosted in a GitHub repository.
Navigate to the Repository:
Open your web browser and go to github.com/cyfrin/rust-crash-course
.
Copy the Clone URL:
On the repository page, click the green "Code" button. You'll see options to clone via HTTPS, SSH, or GitHub CLI. The video demonstration uses SSH, but you can choose HTTPS if you're more comfortable with it or haven't set up SSH keys with GitHub.
Select the "SSH" tab (if using SSH) and copy the provided URL (e.g., git@github.com:Cyfrin/rust-crash-course.git
).
Alternatively, select the "HTTPS" tab and copy that URL.
Clone the Repository Locally:
Open your terminal or command prompt. Navigate to the directory where you want to store the course files. Then, execute the git clone
command followed by the URL you copied:
Or, if using HTTPS:
This command will download the rust-crash-course
repository into a new folder of the same name in your current directory.
rust-analyzer
While you can use any text editor or IDE, this course will use Visual Studio Code (VS Code) for demonstrations. For an optimal Rust development experience in VS Code, we highly recommend installing the rust-analyzer
extension.
Benefits of rust-analyzer
: This extension provides powerful features such as intelligent code completion, real-time error checking, syntax highlighting, go-to-definition, and refactoring tools, significantly enhancing productivity.
Installing rust-analyzer
in VS Code:
Open VS Code.
Navigate to the Extensions view by clicking the Extensions icon in the Activity Bar on the side of the window (or press Ctrl+Shift+X
).
In the search bar, type "rust-analyzer".
Locate the "rust-analyzer" extension published by "The Rust Programming Language".
Click the "Install" button. (If it's already installed, this button may show "Uninstall" or a gear icon for settings).
Although VS Code and rust-analyzer
are recommended for the best learning experience, they are not strictly mandatory to follow the course content.
Please be aware that this setup lesson does not cover the installation of the Rust programming language itself. The process for installing Rust, including rustc
(the Rust compiler) and cargo
(the Rust package manager and build tool), will be detailed in the next video lesson of this course.
Once you've cloned the rust-crash-course
repository, you'll find a structured environment designed to guide you through various Rust concepts.
README.md
: Your Course MapAt the root of the cloned rust-crash-course
directory, you'll find a README.md
file. This file serves as the main table of contents for the entire course. It lists all the topics covered, including:
Data types (scalar types, tuple, array, String, enum, struct, vector, hash map)
Control flow
Ownership
And many other fundamental Rust concepts.
Each topic listed in this README.md
is a hyperlink that will navigate you to the specific folder dedicated to that topic within the repository.
When you click on a topic link in the main README.md
(for example, "Scalar types"), you will be directed to a corresponding folder, typically structured as topics/<topic_name>/
(e.g., topics/scalar/
).
Inside each topic folder, you will consistently find two primary subfolders:
exercises
: This folder contains the Rust project files where you will write your code to complete the exercises for that topic.
solutions
: This folder contains the completed solutions for all exercises in that topic. You can refer to these if you get stuck or want to compare your approach.
The file structure within the exercises
and solutions
subfolders is generally identical to maintain consistency.
README.md
Within each topic's exercises
folder (e.g., topics/scalar/exercises/
), there is another README.md
file. This nested README.md
provides detailed instructions specific to the exercises for that particular topic. It will typically include:
An explanation of any example code provided for the topic.
Clear instructions on what tasks need to be completed for each exercise.
How to run any example code snippets.
For instance, the README.md
in topics/scalar/exercises/
might contain an instruction like:
"Exercise 1: Fix the function
eq
insidesrc/lib.rs
. Compare 2 inputs of the typechar
for equality and return abool
."
src/lib.rs
FileThe actual Rust code you'll be writing for the exercises is usually located in a file named lib.rs
inside the src
directory within a topic's exercises
folder (e.g., topics/scalar/exercises/src/lib.rs
).
todo!()
Macro: Your Starting PointWhen you open an exercise file (like topics/scalar/exercises/src/lib.rs
), you will find function skeletons that use the todo!()
macro as their body:
The todo!()
macro is a special Rust construct. It's a placeholder that allows the Rust project to compile successfully even if a function's logic hasn't been implemented yet. If a function containing todo!()
is called at runtime, the program will panic (i.e., crash) with a message indicating that the functionality is not yet implemented.
To complete an exercise: You need to replace the todo!()
macro within the specified function(s) with your Rust code that correctly implements the required logic.
If you encounter difficulties with an exercise or wish to verify your implementation, the solutions are readily available. Navigate to the corresponding topic's solutions
folder, and you'll find the completed code in the src/lib.rs
file (e.g., topics/scalar/solutions/src/lib.rs
). The video presenter will typically avoid showing solution files to prevent spoilers during the lessons.
The video lessons will often demonstrate Rust concepts using specific code examples. These example files are also included in the repository for your reference. You can find them within the examples
subfolder inside each topic's exercises
directory (e.g., topics/scalar/exercises/examples/
).
For instance, the example code demonstrating scalar types might be located in topics/scalar/exercises/examples/scalar.rs
:
The README.md
file within each topic's exercises
folder (e.g., topics/scalar/exercises/README.md
) will provide the necessary command to run any associated examples. Look for a section titled "Example" or similar.
To run an example using Cargo (Rust's build system and package manager), you'll typically use a command like this from your terminal, ensuring you are in the correct directory (e.g., topics/scalar/exercises/
):
For instance, to run the scalar.rs
example mentioned above, the command would be:
This command instructs Cargo to compile and execute the specified example file. The --release
flag compiles the code with optimizations.
At the bottom of the main README.md
file (located in the root directory of the rust-crash-course
repository), you'll find a "Resources" section. This section contains a curated list of links to valuable external Rust learning materials, such as:
The Rust Programming Language Book (often called "The Book"): The official, comprehensive guide to Rust.
rustlings: A set of small, interactive exercises to get you used to reading and writing Rust code.
Rust by Example: Learn Rust through a series of runnable examples.
Rust Playground: An online environment to write, compile, and run Rust code without any local setup.
These resources are provided for your further exploration and self-study. They will not be directly used or referenced during the video lessons of this crash course but can significantly deepen your understanding of Rust.
With your environment preparation underway, the next critical step is installing the Rust programming language itself. The subsequent video lesson in this course will provide a detailed walkthrough of the Rust installation process. Be sure to complete that before attempting to compile or run any of the exercises or examples.
A key setup guide to Setting Up Your Rust Crash Course Environment - Unlock your Rust learning journey by cloning the course repository and configuring VS Code with the powerful `rust-analyzer`. Master navigating the course structure, understand how to complete exercises via `todo!()`, and run example code with ease.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Introduction to the Rust programming language
Rust variables and functions
Scalar types, arrays, strings, enum, structs, vectors, and hash maps in Rust
Rust control flows: If / else, if let and let else, loop, match
Rust ownership, including borrow and references
Rust error handling
Rust Modules
Rust Traits
Last updated on July 11, 2025
Rust Developer
Rust Programming BasicsDuration: 6min
Duration: 18min
Duration: 47min
Duration: 15min
Duration: 19min
Duration: 8min
Duration: 12min
Duration: 46min
Duration: 14min
Course Overview
About the course
Introduction to the Rust programming language
Rust variables and functions
Scalar types, arrays, strings, enum, structs, vectors, and hash maps in Rust
Rust control flows: If / else, if let and let else, loop, match
Rust ownership, including borrow and references
Rust error handling
Rust Modules
Rust Traits
Last updated on July 11, 2025