# README

## 🦀 **30 Days of Rust**

✨ *Learn Rust step by step in just 30 days! Each topic builds upon the last to take you from beginner to Rustacean pro!*

| 🌟 **Day** |                                                                                 📝 **Topics**                                                                                |
| ---------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| **01**     |                                                         [🦀 **Introduction to Rust**](#-day-1---introduction-to-rust)                                                        |
| **02**     |                          [🔢 **Variables, Data Types**](https://hunterdii.gitbook.io/30-days-of-rust/02_variables-datatypes/02_variables_data_types)                         |
| **03**     |                                      [🔄 **Control Flow**](https://hunterdii.gitbook.io/30-days-of-rust/03_control-flow/03_control_flow)                                     |
| **04**     |                                          [🛠️ **Functions**](https://hunterdii.gitbook.io/30-days-of-rust/04_functions/04_functions)                                         |
| **05**     |                     [⚖️ **Ownership and Borrowing**](https://hunterdii.gitbook.io/30-days-of-rust/05_ownership-and-borrowing/05_ownership_and_borrowing)                     |
| **06**     |                                             [🏗️ **Structs**](https://hunterdii.gitbook.io/30-days-of-rust/06_structs/06_structs)                                            |
| **07**     |                                                [📊 **Enums**](https://hunterdii.gitbook.io/30-days-of-rust/07_enums/07_enums)                                                |
| **08**     |                                       [🧳 **Collections**](https://hunterdii.gitbook.io/30-days-of-rust/08_collections/08_collections)                                       |
| **09**     |                                   [💥 **Error Handling**](https://hunterdii.gitbook.io/30-days-of-rust/09_error-handling/09_error_handling)                                  |
| **10**     |                                            [🧩 **Generics**](https://hunterdii.gitbook.io/30-days-of-rust/10_generics/10_generics)                                           |
| **11**     |                                               [🔧 **Traits**](https://hunterdii.gitbook.io/30-days-of-rust/11_traits/11_traits)                                              |
| **12**     |                             [📦 **Modules and Crates**](https://hunterdii.gitbook.io/30-days-of-rust/12_modules-and-crates/12_modules_and_crates)                            |
| **13**     |                                             [🔍 **Testing**](https://hunterdii.gitbook.io/30-days-of-rust/13_testing/13_testing)                                             |
| **14**     |              [📦 **Cargo and Package Management**](https://hunterdii.gitbook.io/30-days-of-rust/14_cargo-and-package-management/14_cargo_and_package_management)             |
| **15**     |                                               [⚡ **Macros**](https://hunterdii.gitbook.io/30-days-of-rust/15_macros/15_macros)                                               |
| **16**     |                                    [📂 **File Handling**](https://hunterdii.gitbook.io/30-days-of-rust/16_file-handling/16_file_handling)                                    |
| **17**     |                                       [🌀 **Concurrency**](https://hunterdii.gitbook.io/30-days-of-rust/17_concurrency/17_concurrency)                                       |
| **18**     |                    [⚡ **Asynchronous Programming**](https://hunterdii.gitbook.io/30-days-of-rust/18_asynchronous-programming/18_asynchronous_programming)                    |
| **19**     |                                         [🌐 **Networking**](https://hunterdii.gitbook.io/30-days-of-rust/19_networking/19_networking)                                        |
| **20**     |                                       [💀 **Unsafe Rust**](https://hunterdii.gitbook.io/30-days-of-rust/20_unsafe-rust/20_unsafe_rust)                                       |
| **21**     |                                   [⏳ **Rust Lifetimes**](https://hunterdii.gitbook.io/30-days-of-rust/21_rust-lifetimes/21_rust_lifetimes)                                   |
| **22**     |                  [🖥️ **Building CLI Applications**](https://hunterdii.gitbook.io/30-days-of-rust/22_building-cli-applications/22_building_cli_applications)                 |
| **23**     |                            [🌍 **Web Development with Rust**](https://hunterdii.gitbook.io/30-days-of-rust/23_web-development/23_web_development)                            |
| **24**     |                       [🔌 **Integrating with C/C++**](https://hunterdii.gitbook.io/30-days-of-rust/24_integrating_with_c_c++/24_integrating_with_c_c++)                      |
| **25**     |                    [⚙️ **Rust on Embedded Systems**](https://hunterdii.gitbook.io/30-days-of-rust/25_rust-on-embedded-systems/25_rust_on_embedded_systems)                   |
| **26**     |                          [🌐 **Rust and WebAssembly**](https://hunterdii.gitbook.io/30-days-of-rust/26_rust-and-webassembly/26_rust_and_webassembly)                         |
| **27**     |           [🎨 **Graphics Programming with Rust**](https://hunterdii.gitbook.io/30-days-of-rust/27_graphics-programming-with-rust/27_graphics_programming_with_rust)          |
| **28**     |                 [🎮 **Game Development with Rust**](https://hunterdii.gitbook.io/30-days-of-rust/28_game-development-with-rust/28_game_development_with_rust)                |
| **29**     |                  [🤖 **Rust and Machine Learning**](https://hunterdii.gitbook.io/30-days-of-rust/29_rust-and-machine-learning/29_rust_and_machine_learning)                  |
| **30**     | [🎉 **Project Wrap-Up & Advanced Concepts**](https://hunterdii.gitbook.io/30-days-of-rust/30_project-wrap-up-and-advanced-concepts/30_project_wrap_up_and_advanced_concepts) |

🚀 **Happy Coding in Rust!** 🦀

<div align="center"><img src="https://img.shields.io/static/v1?label=%F0%9F%8C%9F&#x26;message=If%20Useful&#x26;style=flat&#x26;color=BC4E99" alt="Star Badge"> <img src="https://img.shields.io/badge/PRs-welcome-brown.svg?longCache=true" alt="Pull Requests"> <img src="https://img.shields.io/github/license/Hunterdii/30-Days-Of-Rust?labelColor=Jade&#x26;color=%2327ae60&#x26;cacheSeconds=3600" alt="MIT License"> <img src="https://badges.frapsoft.com/os/v1/open-source.svg?v=103" alt="Open Source Badge"> <img src="https://img.shields.io/github/contributors/Hunterdii/30-Days-Of-Rust" alt="GitHub Contributors"> <img src="https://img.shields.io/github/last-commit/Hunterdii/30-Days-Of-Rust?display_timestamp=author&#x26;style=flat&#x26;logo=30-Days-Of-Rust&#x26;logoColor=%23F74C00&#x26;logoSize=auto&#x26;label=30%20Days%20Of%20Rust&#x26;labelColor=Lavender&#x26;color=%239b59b6&#x26;cacheSeconds=200" alt="Last Commit"> <img src="https://img.shields.io/badge/Owner-%40Huntedii-%3CCOLOR%3E.svg" alt="Owner Badge"></div>

## Github Stats:

| 🌟 Stars                                                                                        | 🍴 Forks                                                                                        | 🐛 Issues                                                                                         | 📏 Repo Size                                                                                            | 🔔 Open PRs                                                                                                      | 🔕 Closed PRs                                                                                                                             |
| ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| ![Stars](https://img.shields.io/github/stars/Hunterdii/30-Days-Of-Rust?style=flat\&logo=github) | ![Forks](https://img.shields.io/github/forks/Hunterdii/30-Days-Of-Rust?style=flat\&logo=github) | ![Issues](https://img.shields.io/github/issues/Hunterdii/30-Days-Of-Rust?style=flat\&logo=github) | ![Repo Size](https://img.shields.io/github/repo-size/Hunterdii/30-Days-Of-Rust?style=flat\&logo=github) | ![Open Pull Requests](https://img.shields.io/github/issues-pr/Hunterdii/30-Days-Of-Rust?style=flat\&logo=github) | ![Closed Pull Requests](https://img.shields.io/github/issues-pr-closed/Hunterdii/30-Days-Of-Rust?style=flat\&color=critical\&logo=github) |

Support the **author** to create more educational materials\
[![Paypal Logo](https://media3.giphy.com/media/ZEB6yFbLnhyQf7g3hn/giphy.gif)](https://buymeacoffee.com/het81857)

## 🦀 30 Days Of Rust: Day 1 - Introduction 🚀

[![LinkedIn](https://img.shields.io/badge/style--5eba00.svg?label=LinkedIn\&logo=linkedin\&style=social) ](https://www.linkedin.com/in/het-patel-8b110525a/?utm_source=share\&utm_campaign=share_via\&utm_content=profile\&utm_medium=android_app)[![Follow me on GitHub](https://img.shields.io/badge/Follow%20me%20on-GitHub-blue?style=flat-square\&logo=github)](https://github.com/Hunterdii)

***Author:*** [***Het Patel***](https://www.linkedin.com/in/het-patel-8b110525a/?utm_source=share\&utm_campaign=share_via\&utm_content=profile\&utm_medium=android_app)

October, 2024

[Day 2 >>](https://hunterdii.gitbook.io/30-days-of-rust/02_variables-datatypes/02_variables_data_types)

![30DaysOfRust](https://github.com/user-attachments/assets/a1083fb3-3eec-4d1e-b93a-fa4d7a99f180)

* [🦀 30 Days of Rust](#-30-days-of-rust)
* [📘 Day 1 - Introduction to Rust](#-day-1---introduction-to-rust)
  * [👋 Welcome](#-welcome)
  * [🔍 Introduction](#-introduction)
  * [💡 Why Rust?](#-why-rust)
  * [🛠 Environment Setup](#-environment-setup)
    * [📥 Installing Rust](#-installing-rust)
    * [💻 Installing Visual Studio Code](#-installing-visual-studio-code)
      * [🛠 Setting Up Your First Rust Project](#-setting-up-your-first-rust-project)
      * [🎯 Hands-On Challenge](#-hands-on-challenge)
      * [🎥 Helpful Video References](#-helpful-video-references)
  * [📖 Understanding Rust Basics](#-understanding-rust-basics)
    * [🔤 Rust Syntax](#-rust-syntax)
    * [💬 Comments](#-comments)
  * [💻 Exercises - Day 1](#-exercises---day-1)
    * [✅ Exercise: Level 1](#-exercise-level-1)
    * [✅ Exercise: Level 2](#-exercise-level-2)
    * [✅ Exercise: Level 3 (OPTIONAL)](#-exercise-level-3-optional)
  * [📝 Day 1 Summary](#-day-1-summary)

## 📘 Day 1 - Introduction to Rust

### 👋 Welcome

Welcome to **Day 1** of your exciting journey through Rust programming! 🚀 Today, we’ll dive into setting up Rust, exploring its unique features, and writing your very first Rust program. Get ready to embark on a fun and engaging adventure! 🎯

**Congratulations!** 🎉 You've taken the first step in your journey to master the *30 Days of Rust* programming challenge. In this challenge, you will learn the fundamentals of Rust and how to harness its power to write efficient, fast, and safe code. By the end of this journey, you'll have gained a solid understanding of Rust's core concepts and best practices, helping you become a confident Rustacean. 🦀

Feel free to join the [30 Days of Rust](https://discord.gg/dy4gAhng) community on Discord, where you can interact with others, ask questions, and share your progress!

### 🔍 Introduction

Rust is a systems programming language focused on safety, speed, and concurrency. It’s known for its memory safety features and its ability to build fast and efficient software. Whether you're building web applications, embedded software, or system-level programs, Rust is your go-to language. 🦾

Rust is a modern, systems programming language that aims to combine safety, speed, and concurrency. Developed by Mozilla, it’s designed to be a safe alternative to languages like C and C++, without compromising on performance. Rust has quickly gained popularity due to its unique ownership model, which helps prevent common bugs like null pointer dereferencing and data races at compile time.

Throughout this challenge, you’ll learn the latest version of Rust, step-by-step, with easy-to-understand explanations, real-world examples, and hands-on exercises. Whether you’re a beginner or a professional looking to enhance your skills, this challenge will guide you in understanding the core aspects of Rust in a fun, engaging, and motivating way.

### 💡 Why Rust?

Rust is a powerful, yet beginner-friendly language that can be used for various applications such as:

* **Concurrency**: Makes it easier to write concurrent programs.
* **Community**: A growing and welcoming community ready to help you learn.
* **Data science and machine learning**: Rust's speed and safety are attracting developers who are building data-intensive applications.
* **Game development**: Thanks to its high performance, Rust is also suitable for game development.
* **System programming**: Rust’s low-level control over system resources makes it ideal for building operating systems, embedded software, and more.
* **Safety**: Prevents common bugs like null pointer dereferencing and data races.
* **Speed**: Compiles to native code, ensuring faster execution.
* **Web development**: Rust can be used to build both back-end and front-end (with frameworks like Yew).

🔑 *If you’re looking for a language that blends performance with reliability, Rust is the way to go!*

These are just a few of the many use cases that make Rust a versatile and in-demand language. 🌟 Ready to start coding in Rust?

### 🛠 Environment Setup

#### 📥 Installing Rust

To run Rust code, you need to have Rust installed on your system. Let’s get started by [downloading Rust](https://www.rust-lang.org/tools/install). Follow the installation guide to set up Rust:

For Windows users, run this command in the terminal:

```rs
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

For macOS and Linux users, use the same command in your terminal.

Once you have Rust installed, you can verify it by checking the version:

```rs
rustc --version
```

If the command outputs a version number, you’re good to go! 🎉

#### 💻 Installing Visual Studio Code

While Rust can be coded in any text editor, we'll use [Visual Studio Code](https://code.visualstudio.com/) for this challenge. It’s a powerful, customizable, and widely used code editor. If you haven’t already, [download Visual Studio Code](https://code.visualstudio.com/Download) and set it up.

Make sure to install the **Rust extension** on Visual Studio Code for syntax highlighting, code formatting, and error checking:

1. Open Visual Studio Code.
2. Go to **Extensions** (or press `Ctrl+Shift+X`).
3. Search for `rust-analyzer` and install it.

Now, you're ready to start coding! ✨

#### 🛠 Setting Up Your First Rust Project

Let’s create our first Rust project using Cargo, Rust's package manager. Open your terminal and run:

```rs
cargo new hello-rust
```

This command will create a new directory named `hello-rust` with the necessary files. Change to the project directory:

```rs
cd hello-rust
```

Inside, you'll find `Cargo.toml` (a manifest file for Rust projects) and a `src` directory containing `main.rs`. Let's explore what’s inside.

```rs
fn main() {
    println!("Hello, Rust!");
}
```

To run your first Rust program, type:

```rs
cargo run
```

You should see the output:

```rs
Hello, Rust!
```

Congratulations! 🎉 You’ve successfully set up your Rust development environment and run your first Rust program.

🛡️ *Boom! You’ve successfully written and executed your first Rust program!*

### 🎯 Hands-On Challenge

Create a Rust program that prints your name and the reason you're excited to learn Rust. Here’s a template to get you started:

```rs
fn main() {
    let name = "Your Name";
    let reason = "I'm excited to learn Rust because it's fast and reliable!";
    println!("Hello, my name is {} and {}.", name, reason);
}
```

✅ **Share your solution on GitHub and tag `#30DaysOfRust` on social media!** Let the world know you’ve begun your Rust journey! 🚀

### 🎥 Helpful Video References

Get a better understanding of Rust and how it works by checking out these great resources:

1. [**Rust for Beginners - Complete Guide**](https://www.youtube.com/watch?v=8O0Nt9qY_vo)\
   \&#xNAN;*A comprehensive guide that walks you through the basics of Rust.*
2. [**Why Rust? - A Love Letter to Rust**](https://www.youtube.com/watch?v=pW4yuT2Gk54)\
   \&#xNAN;*Learn why Rust has become so popular in recent years.*
3. [**Build Your First Rust Project**](https://www.youtube.com/watch?v=pGh-0cMvH5g)\
   \&#xNAN;*Create a complete project from scratch with this hands-on video.*

### 📖 Understanding Rust Basics

#### 🔤 Rust Syntax

Rust syntax is clear and concise, making it easy to write and understand. Let’s explore some of the essential elements you’ll need to get started.

#### 💬 Comments

In Rust, comments are crucial for explaining your code and making it more understandable. They can be categorized into non-doc comments and doc comments.

* Non-doc Comments
  * Single-Line Comments
  * MultiLine Comments
* Doc Comments
  * Outer doc comments
  * Inner doc comments

#### Non-Doc Comments

Non-doc comments are used to annotate your code without being part of the documentation generated by tools like `rustdoc`. They are primarily for developers working directly with the code.

**Single-Line Comments**

Single-line comments start with `//` and continue to the end of the line. They are useful for short explanations.

**Example:**

```rs
fn main() {
    let x = 5; // This is a single-line comment
    println!("Value of x: {}", x);
}
```

*Output:*

```
Value of x: 5
```

**Multi-Line Comments**

Multi-line comments start with `/*` and end with `*/`. They can span multiple lines, making them suitable for longer explanations.

**Example:**

```rs
fn main() {
    /* This is a multi-line comment.
       It can span multiple lines.
       The next line will print the value of x. */
    let x = 10;
    println!("Value of x: {}", x);
}
```

*Output:*

```
Value of x: 10
```

#### Doc Comments

Doc comments are used to document public APIs and generate documentation using tools like `rustdoc`. They start with `///` for outer doc comments and `//!` for inner doc comments.

**Outer Doc Comments**

Outer doc comments are placed before functions, structs, or modules and are used to describe them in the generated documentation.

**Example:**

```rs
/// This function adds two numbers and returns the result.
fn add(a: i32, b: i32) -> i32 {
    a + b
}
```

In this example, `///` provides a description of what the `add` function does. This comment will appear in the documentation generated by `rustdoc`.

**Inner Doc Comments**

Inner doc comments are placed within the context of a module, function, or struct, usually to provide more details about the implementation.

**Example:**

````rs
/// A structure representing a point in 2D space.
struct Point {
    x: f64,
    y: f64,
}

impl Point {
    /// Creates a new Point at the given coordinates.
    ///
    /// # Examples
    ///
    /// ```
    /// let p = Point::new(1.0, 2.0);
    /// ```
    fn new(x: f64, y: f64) -> Self {
        Point { x, y }
    }
}
````

In this example, `///` describes the `Point` struct and the `new` method. The `///` before the `new` method serves as a doc comment that explains what the method does and provides an example.

### 💻 Exercises - Day 1

#### ✅ Exercise: Level 1

1. Create a new Rust project using Cargo.
2. Write a program that prints `Hello, World!` to the console.
3. Verify that Rust is installed correctly by checking its version.

#### ✅ Exercise: Level 2

1. Modify the `main.rs` file to declare an immutable variable `x` with the value of `5`.
2. Change `x` to be mutable and update its value to `10`.

#### ✅ Exercise: Level 3 (OPTIONAL)

1. Write a Rust program that declares different data types (integer, float, boolean, string) and prints them.
2. Experiment with different control flow structures (`if`, `else`, `for`, `while`).

### 📝 Day 1 Summary

* We covered the **installation of Rust**.
* You wrote your **first Rust program**.
* You explored **helpful video resources** to dive deeper into Rust.
* You completed your first **hands-on challenge**.

👏 *Well done on making it through Day 1! Pat yourself on the back and get ready for the next step!*

🌕 Great job! You have completed Day 1 of the *30 Days of Rust* challenge! Keep practicing, and get ready for Day 2 where you'll dive deeper into Rust basics.

Thank you for joining **Day 1** of the 30 Days of Rust challenge! If you found this helpful, don’t forget to ![Star GIF](https://github.com/user-attachments/assets/35f6838c-52f5-4e48-8a98-c5203f8c57e3) star this repository, share it with your friends, and stay tuned for more exciting lessons ahead!

**Stay Connected**\
📧 **Email**: [Hunterdii](mailto:hunterdii9879@gmail.com)\
🐦 **Twitter**: [@HetPate94938685](https://twitter.com/HetPate94938685)\
🌐 **Website**: [Working On It(Temporary)](https://hunterdii.github.io/Portfolio-Temporary/)

[Day 2 >>](https://hunterdii.gitbook.io/30-days-of-rust/02_variables-datatypes/02_variables_data_types)

***
