From 5aa19580220dbe91d2b98cec4fe29fea231391c5 Mon Sep 17 00:00:00 2001 From: dcodes <101001810+dcodesdev@users.noreply.github.com> Date: Sat, 30 Nov 2024 12:35:53 +0300 Subject: [PATCH 1/8] typo fix (#54) --- challenges/control-flow/description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenges/control-flow/description.md b/challenges/control-flow/description.md index 247b1d9..0790c45 100644 --- a/challenges/control-flow/description.md +++ b/challenges/control-flow/description.md @@ -27,5 +27,5 @@ assert_eq!(result, "zero"); ## Hints -- You can use the `if`, `else-if`, and `else` keywords to implement the control flow. +- You can use the `if`, `else if`, and `else` keywords to implement the control flow. - Remember to return the result as a `String`. From 35caf14f306cd361db4d61761991e69dc597a448 Mon Sep 17 00:00:00 2001 From: dcodes <101001810+dcodesdev@users.noreply.github.com> Date: Mon, 9 Dec 2024 20:24:30 +0300 Subject: [PATCH 2/8] Fix: Long comments caused a UI bug (#64) --- challenges/ownership/description.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/challenges/ownership/description.md b/challenges/ownership/description.md index 6dc1cfe..2ad8e9d 100644 --- a/challenges/ownership/description.md +++ b/challenges/ownership/description.md @@ -12,7 +12,8 @@ In Rust, each value has a variable that's called its **owner**. There can only b ```rust { - let s = String::from("hello"); // s is the owner of the String + // s is the owner of the String + let s = String::from("hello"); } // s goes out of scope and "hello" is dropped ``` @@ -30,11 +31,13 @@ You can create multiple **immutable references** to a value, but you cannot have fn main() { let s1 = String::from("hello"); - let len = calculate_length(&s1); // borrow s1 as immutable + // Borrow s1 as immutable + let len = calculate_length(&s1); println!("The length of '{}' is {}.", s1, len); } -fn calculate_length(s: &String) -> usize { // s is an immutable reference to a String +// s is an immutable reference to a String +fn calculate_length(s: &String) -> usize { s.len() } ``` From d83bce9ce32006ad17438abe96f2c3f20a3e5caa Mon Sep 17 00:00:00 2001 From: dlloyd1 Date: Mon, 9 Dec 2024 17:28:41 +0000 Subject: [PATCH 3/8] Typo fix (#62) --- challenges/graceful-error-handling/description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenges/graceful-error-handling/description.md b/challenges/graceful-error-handling/description.md index 2e849a5..78b1193 100644 --- a/challenges/graceful-error-handling/description.md +++ b/challenges/graceful-error-handling/description.md @@ -6,7 +6,7 @@ When you have a function that can fail, you can use the `Result` type to return ## Your task -In this challenges, you're given a function, `parse_percentage(input: &str) -> Result` that takes a string as input and returns a `Result` type. The function should parse the input string as a percentage and return the percentage as a `u8` if the input is valid. If the input is invalid, the function should return an error message as a `String`. +In this challenge, you're given a function, `parse_percentage(input: &str) -> Result` that takes a string as input and returns a `Result` type. The function should parse the input string as a percentage and return the percentage as a `u8` if the input is valid. If the input is invalid, the function should return an error message as a `String`. Parsing from a string to a number can fail for many reasons. For example, the input string may not be a valid number, or it may be a valid number but not a valid percentage. Your task is to handle these errors gracefully and return an error message that explains what went wrong. From 898349591e3ad02dd76a18870c50fe1606850724 Mon Sep 17 00:00:00 2001 From: Wendy Kong Date: Wed, 11 Dec 2024 18:16:37 +0000 Subject: [PATCH 4/8] Renamed the instructions so that it matches the boilerplate code (#65) --- challenges/animal-sanctuary-registry/description.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/challenges/animal-sanctuary-registry/description.md b/challenges/animal-sanctuary-registry/description.md index ff7c056..2e3e00c 100644 --- a/challenges/animal-sanctuary-registry/description.md +++ b/challenges/animal-sanctuary-registry/description.md @@ -12,9 +12,9 @@ Your task is to implement the following functions: 1. `add_animal_to_section`: This function should add an animal to a section in the registry. If the section does not exist, it should be created. If the animal is already in the section, it should not be added again. -2. `get_animals_in_section`: This function should return a list of animals sorted **alphabetically** in a given section. If the section does not exist, it should return an empty list. +2. `get_animals_in_section`: This function should return a list of animals **sorted alphabetically** in a given section. If the section does not exist, it should return an empty list. -3. `get_all_animals`: This function should return a copy of the entire registry with all animals **sorted alphabetically** in each section. +3. `get_all_animals_sorted`: This function should return a copy of the entire registry with all animals **sorted alphabetically** in each section. ## Example From d353d1071a1888f391348dbd647889b79fd23266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Ribaud?= Date: Fri, 13 Dec 2024 01:01:00 +0100 Subject: [PATCH 5/8] Fix a small typo (#69) --- challenges/animal-sanctuary-registry/description.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenges/animal-sanctuary-registry/description.md b/challenges/animal-sanctuary-registry/description.md index 2e3e00c..423832a 100644 --- a/challenges/animal-sanctuary-registry/description.md +++ b/challenges/animal-sanctuary-registry/description.md @@ -2,7 +2,7 @@ Hashmaps are a powerful data structure that allow you to store **key-value pairs**. In Rust, the `HashMap` type is provided that uses the a **hashing algorithm** called **SipHash** to store keys and values in a way that allows for **fast and secure** lookups. Think of them as a dictionary in Python or an object in JavaScript. -In this challenge, we want to build a sanctuary registry that allows us to manage animals in different sections of the sanctuary. We'll use a `HashMap` to store the sections as keys and a `Vec` to store the animals in each section. Each key is a section name `String` and each value is a list of animals in that section `Vev`. +In this challenge, we want to build a sanctuary registry that allows us to manage animals in different sections of the sanctuary. We'll use a `HashMap` to store the sections as keys and a `Vec` to store the animals in each section. Each key is a section name `String` and each value is a list of animals in that section `Vec`. ## Task From cbb7ab2bb4769e0fa467bb1f39adba1675c24fdb Mon Sep 17 00:00:00 2001 From: Tony Ruiz Date: Wed, 25 Dec 2024 14:21:01 -0500 Subject: [PATCH 6/8] Hint udpate (#72) --- challenges/declaring-variables/description.md | 1 + 1 file changed, 1 insertion(+) diff --git a/challenges/declaring-variables/description.md b/challenges/declaring-variables/description.md index bfcaf63..64cf6e3 100644 --- a/challenges/declaring-variables/description.md +++ b/challenges/declaring-variables/description.md @@ -25,4 +25,5 @@ Then, calculate the area of a rectangle using the formula `area = width * height - Use the `let` keyword to declare variables. - Remember that variables declared with `let` are immutable by default. +- You do not need to explicitly annotate the types (e.g., `let width: u32 = 10;`) for the variables. - Use multiplication `*` to calculate the area. From f7259fbcf134572d8c161743a98b68917ee3d2da Mon Sep 17 00:00:00 2001 From: dcodes <101001810+dcodesdev@users.noreply.github.com> Date: Fri, 27 Dec 2024 19:05:04 +0300 Subject: [PATCH 7/8] CHORE: README.md, LICENSE (#76) --- LICENSE | 36 +++++++++++++ README.md | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 184 insertions(+), 6 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..aea9ffc --- /dev/null +++ b/LICENSE @@ -0,0 +1,36 @@ +Copyright (c) 2024-present Rustfinity. +All Rights Reserved. + +1. License Grant + Subject to the terms and conditions of this License, the Licensor hereby grants you a limited, non-exclusive, non-transferable, non-sublicensable right to view and use the software. This right is strictly for internal evaluation, testing, and development purposes only. + +2. Restrictions + +- You may not distribute, sublicense, sell, lease, rent, loan, or otherwise transfer the software or any portion of it to any third party without express written permission from the Licensor. +- You may not modify, adapt, or create derivative works of the software unless explicitly permitted by the Licensor in writing. +- You may not remove or alter any copyright notices, proprietary notices, trademarks, or other identifying marks from the software. + +3. Ownership + +- The Licensor retains all right, title, and interest in and to the software, including all intellectual property rights. +- No rights or licenses are granted by implication or estoppel. + +4. Disclaimer of Warranty + +- The software is provided on an “AS IS” basis without warranties or conditions of any kind, either express or implied, including, without limitation, warranties or conditions of merchantability, fitness for a particular purpose, or non-infringement. +- The software is provided "as is" and no guarantees or warranties of any kind are provided. +- You assume all responsibility and risk for the use of the software. + +5. Limitation of Liability + To the maximum extent permitted by law, in no event shall the Licensor be liable for any direct, indirect, incidental, special, exemplary, or consequential damages. This includes, but is not limited to, procurement of substitute goods or services, loss of use, data, or profits, or business interruption, however caused and under any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of the software. + +6. Termination + +- This License is effective until terminated. +- Your rights under this License will terminate automatically without notice if you fail to comply with any of its terms. +- Upon termination, you must immediately cease all use of the software and destroy or return all copies of the software in your possession or control. + +7. Entire Agreement + This License constitutes the entire agreement between you and the Licensor concerning the software and supersedes all prior or contemporaneous understandings regarding such subject matter. Any modifications to this License must be in writing and signed by both parties. + +If you do not agree with the terms of this License, you are not allowed to use or access the software in any manner. diff --git a/README.md b/README.md index d1e62e5..68d5afa 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,155 @@ -![Rustfinity.com](/images/rustfinity-header.png) +[![Rustfinity Banner](./images/rustfinity-header.png)](https://rustfinity.com) # Rustfinity -A repository for all the publicly available content for Rustfinity. +

+ Website + License + Issues + Pull Requests +

-## Crates +Rustfinity is an **interactive learning platform** dedicated to helping Rust developers of all levels learn and practice Rust programming concepts. +**[Visit our website → rustfinity.com](https://rustfinity.com)** to explore challenges, tutorials, and everything you need to level up your Rust skills! -- [CLI](crates/cli/) +> **Why Rustfinity?** +> +> - **Hands-on Learning**: Practice your Rust skills with real challenges in a fun environment. +> - **Comprehensive Exercises**: From basics to advanced topics—there’s something for everyone. +> - **Engaging Community**: Contribute, discuss, and grow alongside other Rust enthusiasts! -## Challenges +--- -- [Challenges](challenges/) +## Table of Contents + +- 🚀 [Getting Started](#-getting-started) +- 📂 [Folder Structure](#-folder-structure) + - [challenges/](#challenges) + - [crates/](#crates) +- 🤖 [Crates](#-crates-details) + - [cli](#cli) + - [rustfinity-runner](#rustfinity-runner) + - [syntest](#syntest) +- ❤️ [Contribute](#-contribute) +- 🏠 [Local Development](#-local-development) +- 🔗 [Follow Us](#-follow-us) +- ⚖️ [License](#-license) + +--- + +## 🚀 Getting Started + +1. **Head to [rustfinity.com](https://rustfinity.com)** + Explore available challenges and pick the ones you want to tackle. +2. **Try out the `cli` crate (optional)** + You can download challenges and practice them locally right from your terminal. +3. **Dive into the code** + Explore this repository to see how challenges and crates are structured. + +--- + +## 📂 Folder Structure + +```bash +. +├── challenges/ +│ ├── challenge-1/ +│ │ ├── description.md +│ │ ├── src/ +│ │ │ ├── lib.rs +│ │ │ └── starter.rs +│ │ └── tests/ +│ │ └── tests.rs +│ └── challenge-2/ (and so on...) +└── crates/ + ├── cli + ├── rustfinity-runner + └── syntest +``` + +### challenges/ + +This directory holds all the coding challenges served on [rustfinity.com](https://rustfinity.com). Feel free to submit new challenges, improve existing ones, or solve them locally using our CLI. + +### crates/ + +This folder contains multiple Rust crates that power the Rustfinity platform. + +--- + +## 🤖 Crates + +### `cli` + +- **What is it?** + The Rustfinity Command-Line Interface to help you **download, solve, and submit** Rustfinity challenges locally. +- **Key Features** + - Download any challenge directly to your local environment + - Submit solutions with `rustfinity submit` which redirects you to the challenge page with your solution + +### `rustfinity-runner` + +- **What is it?** + A crate designed for running challenge tests inside a secure Docker container. +- **Key Features** + - Spins up a temporary Docker container to safely execute user code + - Logs outputs and results from test runs + - Ensures a clean environment for each challenge submission + +### `syntest` + +- **What is it?** + A specialized testing library built on top of Rust’s [`syn`](https://docs.rs/syn) library to analyze and validate Rust code syntax. +- **Key Features** + - Parse Rust AST (Abstract Syntax Tree) for testable patterns + - Provides an easy interface for writing **syntax-based** tests + - Helps ensure your Rust code meets style and syntactic guidelines + +--- + +## ❤️ Contribute + +We’d love your help! Whether it’s fixing bugs, adding challenges, or improving docs, every bit of help **matters**. + +1. **Check out our [issues](https://github.com/dcodesdev/rustfinity.com/issues)**: Found a bug or want to suggest an enhancement? Open an issue! +2. **Fork & PR**: Fork the repo, make changes, and submit a pull request. +3. **Join our Discord**: [Join our Discord server](https://discord.gg/8GRcUqY48B) to discuss ideas, ask questions, or just hang out with the community. +4. **Spread the word**: Share Rustfinity with your friends, colleagues, or on social media. + +--- + +## 🏠 Local Development + +Ready to hack on Rustfinity locally? Here’s how: + +```bash +# 1. Clone the repository +git clone https://github.com/dcodesdev/rustfinity.com.git +cd rustfinity.com + +# 2. (Optional) Switch to a new branch for your work +git checkout -b my-new-feature + +# 3. Explore and build +cargo build +``` + +We recommend installing [Docker](https://www.docker.com/) if you want to test the `rustfinity-runner` crate in a containerized environment. + +--- + +## 🔗 Follow Us + +Stay updated with the latest challenges, features, and announcements! + +

+ X + GitHub + Discord +

+ +--- + +## ⚖️ License + +This project is licensed under the [Rustfinity Proprietary License](https://github.com/dcodesdev/rustfinity.com/blob/main/LICENSE). From 078cdf65d0ce7c72bc714a746ae4b60f9d4364a8 Mon Sep 17 00:00:00 2001 From: Markus Bergkvist Date: Fri, 27 Dec 2024 18:49:22 +0100 Subject: [PATCH 8/8] Add test case for negative to positive range (#75) --- challenges/find-the-first-palindrome/tests/tests.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/challenges/find-the-first-palindrome/tests/tests.rs b/challenges/find-the-first-palindrome/tests/tests.rs index 49f8086..a6dc998 100644 --- a/challenges/find-the-first-palindrome/tests/tests.rs +++ b/challenges/find-the-first-palindrome/tests/tests.rs @@ -26,4 +26,9 @@ mod tests { fn test_find_first_palindrome_edge_case() { assert_eq!(find_first_palindrome(1, 1), Some(1)); } + + #[test] + fn test_find_first_palindrome_negative_range() { + assert_eq!(find_first_palindrome(-1, 1), Some(0)); + } }