Welcome to my Rust learning journey! This repository contains a series of mini-projects that I have completed while learning the Rust programming language. Each project focuses on different aspects of Rust, from basic syntax and control flow to more advanced concepts like memory management and concurrency.
This is a simple command-line guessing game where the user has to guess a randomly generated number between 1 and 100. The game provides feedback on whether the guessed number is too small, too big, or correct. The game continues until the correct number is guessed.
- Basic Rust syntax, including
fnfor functions,letfor variable declaration, and theloopkeyword. - How to use the
randcrate to generate random numbers. - How to handle user input with the
std::iomodule. - Basic error handling in Rust using
expect. - Parsing strings to integers using
trim()andparse().
This is a simple command-line calculator that allows the user to input two numbers and perform basic arithmetic operations (addition, subtraction, multiplication, and division). The program handles input parsing, validates the user's input, and performs the selected operation.
- How to use the
std::iomodule to handle input and output in Rust. - Implementing basic arithmetic operations with functions.
- Using
f64::is_nanto validate input. - Understanding the
matchstatement for control flow. - Parsing and converting string inputs to floating-point numbers.
Here's a README section tailored for your string reversal project:
This project is a command-line tool that allows the user to input a string and returns the string in reverse order. The program demonstrates basic string manipulation in Rust, including reading user input, processing strings, and outputting results to the console.
- Handling user input using the
std::iomodule. - String manipulation in Rust, including trimming whitespace and reversing characters.
- Working with functions, including passing arguments and returning values.
- Understanding string slices (
&str) and heap-allocatedStringtypes. - Basics of Rust's memory management and ownership model.
This project is a command-line tool that detects the language of the input text using the whatlang crate. The program reads a string provided by the user, analyzes it to determine the language, script, confidence level, and reliability of the detection, and then outputs these details to the console.
- Language Detection: Utilized the whatlang crate to identify the language of the input text.
- User Input Handling: Managed user input and output using the std::io module, including reading from the console and flushing output.
- String Processing: Worked with string slices (&str) and the String type for text manipulation.
- Error Handling: Implemented basic error handling for cases where language detection may fail, using match for more robust error handling.
- CLI Development: Built a simple command-line interface (CLI) application that interacts with users and processes their input.
The Task Manager is a simple command-line interface (CLI) tool written in Rust that helps users manage their to-do list. The tool allows users to add tasks, list all tasks, and mark tasks as completed. It is a beginner-friendly project designed to demonstrate basic concepts in Rust, including struct usage, method implementation, and control flow.
- Add Tasks: Users can add new tasks to their to-do list.
- List Tasks: The tool displays all tasks along with their completion status.
- Complete Tasks: Users can mark tasks as completed.
- Structs and Methods: How to define and implement methods for custom data types.
- Vector Manipulation: Storing and manipulating a dynamic list of tasks.
- Input Handling: Reading and processing user input from the command line.
- Control Flow: Using loops and pattern matching to create an interactive menu.
- Error Handling: Managing potential errors and ensuring a smooth user experience.