Rust Logo

Explore the World of Rust Programming

Rust is a language empowering everyone to build reliable and efficient software. Dive into our curated resources to learn, explore libraries, and discover practical examples.

Start Exploring
Learn Library Example

Getting Started with Rust

Rust is a modern, high-performance, and safe systems programming language. It is designed to provide...

Installation and Hello World

Rust is a modern systems programming language known for its speed, memory safety, and concurrency. B...

Programming a Guessing Game

A guessing game is a classic introductory programming project that involves a user trying to guess a...

Common Programming Concepts

Common programming concepts are the fundamental building blocks and ideas that are prevalent across ...

Variables and Mutability

In Rust, variables are fundamental for storing data. A key concept to grasp is that variables are im...

Data Types

In programming, data types are classifications that tell the compiler or interpreter how the program...

Functions

Functions are blocks of organized, reusable code that perform a single, related action. They are fun...

Comments

In programming, comments are explanatory notes or annotations embedded within the source code. They ...

Control Flow

Control flow refers to the order in which individual statements, instructions, or function calls of ...

Understanding Ownership in Rust

Ownership is Rust's most unique feature and a core concept for understanding how Rust achieves memor...

What is Ownership in Rust?

Rust's most distinctive feature and perhaps the most challenging for newcomers is Ownership. It's Ru...

References and Borrowing

In Rust, 'ownership' is a core concept that manages memory without a garbage collector. However, pas...

The Slice Type

In Rust, a slice is a reference to a contiguous sequence of elements in a collection, rather than th...

Using Structs to Structure Related ...

In programming, structs (short for structures) are custom data types that allow you to package toget...

Defining and Instantiating Structs

Structs, short for "structures," are custom data types that let you group together related pieces of...

An Example Program Using Structs in...

In Rust, structs (short for "structures") are custom data types that let you package together relate...

Method Syntax

In Rust, methods are functions associated with an instance of a particular data type (like a struct ...

Enums and Pattern Matching

In Rust, `enums` (enumerations) are custom data types that allow you to define a type by enumerating...

Defining an Enum

In Rust, an enumeration, or `enum`, is a custom data type that allows you to define a type by enumer...

The match Control Flow Construct

The `match` control flow construct in Rust is a powerful tool for controlling program flow by compar...

Concise Control Flow with if let

In Rust, `if let` provides a concise way to handle patterns that match a single variant of an enum, ...

Managing Growing Projects with Pack...

As software projects grow in size and complexity, effective organization becomes paramount for maint...

Packages and Crates

In Rust, the concepts of 'Packages' and 'Crates' are fundamental to organizing, compiling, and distr...

Defining Modules to Control Scope a...

Rust's module system is a fundamental feature for organizing code, controlling visibility (privacy),...

Paths for Referring to an Item in t...

In Rust, code is organized into modules, which form a tree-like structure. To access items (function...

Bringing Paths into Scope with the ...

In Rust, items (such as functions, structs, enums, modules, or traits) are organized into modules, f...

Separating Modules into Different F...

In Rust, modules are a fundamental way to organize code within a crate. As projects grow, keeping al...

Common Collections

In Rust, common collections are data structures that store multiple values. Unlike built-in array ty...

Storing Lists of Values with Vector...

In Rust, a 'Vector' (specifically `Vec<T>`) is a growable list type provided by the standard library...

Storing UTF-8 Encoded Text with Str...

UTF-8 (Unicode Transformation Format - 8-bit) is a variable-width character encoding that can repres...

Storing Keys with Associated Values...

Hash Maps, also known as Dictionaries in some languages or Associative Arrays, are fundamental data ...

Error Handling

Error handling is a crucial aspect of robust software development, ensuring that programs can gracef...

Unrecoverable Errors with panic!

In Rust, errors are broadly categorized into two types: recoverable and unrecoverable. Recoverable e...

Recoverable Errors with Result

In Rust, errors are broadly categorized into two types: recoverable and unrecoverable. Recoverable e...

To panic! or Not to panic!

Rust's philosophy around error handling distinguishes between *recoverable* errors and *unrecoverabl...

Generic Types, Traits, and Lifetime...

Rust's type system is powerful, and three core features—Generic Types, Traits, and Lifetimes—are...

Generic Data Types

Generic Data Types are a fundamental concept in modern programming languages, including Rust, that e...

Traits: Defining Shared Behavior

In Rust, traits are a powerful feature that allows you to define shared behavior, or a set of method...

Validating References with Lifetime...

In Rust, references are pointers to data owned by another part of the program. A crucial aspect of R...

Writing Automated Tests

Automated testing is a software development practice where specialized code is written to verify the...

How to Write Tests

Testing is a crucial part of software development that helps ensure the correctness and reliability ...

Controlling How Tests Are Run in Ru...

Running tests efficiently and effectively is crucial for maintaining code quality. Rust's `cargo tes...

Test Organization in Rust

Test organization is crucial for maintaining a robust, scalable, and understandable test suite, espe...

An I/O Project: Building a Command ...

Building a Command Line Interface (CLI) program is a fundamental project for understanding input/out...

Accepting Command Line Arguments

Command-line arguments are parameters passed to a program when it is executed from the command line ...

Reading a File in Rust

Reading a file is a fundamental operation in many applications, allowing programs to access stored d...

Refactoring to Improve Modularity a...

Refactoring is the process of restructuring existing computer code without changing its external beh...

Developing the Library’s Functional...

Test Driven Development (TDD) is a software development process that relies on the repetition of a v...

Working with Environment Variables

Environment variables are dynamic named values that can affect the way running processes behave on a...

Writing Error Messages to Standard ...

In programming, it's a fundamental best practice to differentiate between a program's regular output...

Functional Language Features: Itera...

Functional programming emphasizes pure functions, immutability, and declarative code. Rust, while no...

Closures: Anonymous Functions that ...

Closures are anonymous functions that can capture values from the environment in which they are defi...

Processing a Series of Items with I...

In Rust, iterators provide a powerful and idiomatic way to process sequences of items. They are a co...

Improving Our I/O Project

Input/Output (I/O) operations are often the slowest parts of an application, involving interaction w...

Comparing Performance: Loops vs. It...

In many programming languages, the question of whether traditional `for` or `while` loops are faster...

More about Cargo and Crates.io

Cargo is the official Rust build system and package manager, an indispensable tool for Rust develope...

Publishing a Crate to Crates.io

Publishing a Rust crate to Crates.io is the standard way to share your libraries and tools with the ...

Cargo Workspaces

Cargo Workspaces provide a way to manage multiple related packages (crates) within a single reposito...

Installing Binaries from Crates.io ...

The `cargo install` command is a powerful feature of Cargo, Rust's package manager, that allows deve...

Extending Cargo with Custom Command...

Cargo is Rust's build system and package manager. While it provides many built-in commands like `bui...

Smart Pointers

Smart pointers are data structures that act like pointers but also have additional metadata and capa...

Using Box<T> to Point to Data on th...

In Rust, `Box<T>` is a smart pointer that allows you to allocate values on the heap instead of the s...

Treating Smart Pointers Like Regula...

In Rust, smart pointers are data structures that act like pointers but also have additional metadata...

Running Code on Cleanup with the Dr...

In Rust, memory and other resources are automatically released when their owners go out of scope. Th...

Rc<T>, the Reference Counted Smart ...

Rust's ownership system ensures memory safety at compile time by enforcing strict rules: a value can...

RefCell<T> and the Interior Mutabil...

In Rust, the ownership and borrowing rules are fundamental to its memory safety guarantees. These ru...

Reference Cycles Can Leak Memory

Memory leaks occur when allocated memory is no longer needed but cannot be deallocated, leading to i...

Fearless Concurrency

Fearless Concurrency is a core philosophy and feature of the Rust programming language that allows d...

Using Threads to Run Code Simultane...

Threads are fundamental units of execution within a process that allow a program to perform multiple...

Using Message Passing to Transfer D...

Message passing is a concurrency model where threads (or processes) communicate by sending and recei...

Shared-State Concurrency

Shared-state concurrency is a paradigm in concurrent programming where multiple threads or processes...

Extensible Concurrency with the Syn...

Rust's approach to concurrency is unique, relying heavily on its ownership system and type system to...

Object Oriented Programming Feature...

Rust is not an object-oriented language in the traditional sense, like Java or C++. It is a multi-pa...

Characteristics of Object-Oriented ...

Object-Oriented Programming (OOP) is a programming paradigm based on the concept of 'objects', which...

Using Trait Objects That Allow for ...

Trait objects in Rust provide a mechanism for achieving runtime polymorphism, allowing you to work w...

Patterns and Matching

Patterns are special syntax in Rust for matching against the structure of values. Matching is the ac...

All the Places Patterns Can Be Used...

Patterns are a powerful feature in Rust that allow you to destructure values, control program flow, ...

Refutability: Whether a Pattern Mig...

In Rust, patterns are used to destructure values, bind variables, and control program flow. The conc...

Pattern Syntax in Rust

Rust's pattern syntax is a powerful and versatile feature that allows you to match against the struc...

Advanced Features in Rust

Rust's primary focus on memory safety and concurrency without garbage collection is achieved through...

Unsafe Rust

Unsafe Rust is a subset of the Rust programming language that allows developers to opt out of some o...

Advanced Traits

Advanced Traits in Rust refer to features that go beyond basic trait definition and implementation, ...

Advanced Types in Rust

Rust's type system is incredibly powerful, offering not just basic data types but also a suite of ad...

Advanced Functions and Closures

In Rust, functions and closures are powerful constructs that enable flexible and expressive code, es...

Macros

Macros in Rust are a form of metaprogramming, which means they are code that writes other code. They...

Final Project: Building a Multithre...

Understanding Multithreaded Web Servers\n\nA web server is a program that listens for incoming netw...

Building a Single-Threaded Web Serv...

Building a single-threaded web server is a fundamental exercise for understanding network programmin...

Turning Our Single-Threaded Server ...

Introduction to Single-Threaded Servers A single-threaded server processes client requests sequent...

Graceful Shutdown and Cleanup

Graceful shutdown and cleanup refer to the process of terminating a running application in an orderl...