Arrays/Vectors
#Arrays are fixed-size collections of elements of the same type, stored on the stack. Vectors (`Vec<T>`) are growable, heap-allocated lists of elements of the same type.
Rust is a statically typed, compiled systems programming language designed for performance, memory safety, and safe concurrency—without relying on an automated garbage collector.
Launch interactive study modes or print uniform flashcard sheets.
Review definitions, formulas, and aliases included in this glossary.
Arrays are fixed-size collections of elements of the same type, stored on the stack. Vectors (`Vec<T>`) are growable, heap-allocated lists of elements of the same type.
Associated types are placeholders for types within a trait definition. They allow a trait to be generic over some types without making the trait itself generic.
A BinaryHeap<T> in Rust is a priority queue implementation provided by the standard library under std::collections::BinaryHeap. It allows you to efficiently store elements and always have quick access to the "greatest" element.
Borrowing allows temporary access to data owned by another variable without taking ownership. References (& or &mut) are used for borrowing, adhering to strict rules to prevent data races.
A BTreeMap<K, V> in Rust is a map collection based on a B-tree data structure, located in the standard library under std::collections::BTreeMap. Like a HashMap, it stores data as key-value pairs, but with distinct characteristics regarding ordering and performance.
A BTreeSet<T> in Rust is a collection that stores a group of unique values sorted in ascending order. It is part of the standard library under std::collections::BTreeSet and acts as the sorted equivalent to a HashSet.
Cargo is Rust's build system and package manager. It handles creating projects, managing dependencies, compiling code, running tests, and generating documentation.
Closures are anonymous functions that can capture values from the scope in which they are defined. They are often used as arguments to functions that take callbacks.
Rust's concurrency model focuses on memory safety without data races. It uses ownership and borrowing rules, along with traits like `Send` and `Sync`, to enable safe parallel programming.
Control flow constructs like `if`, `else`, `loop`, `while`, and `for` determine the order in which code is executed. `match` expressions offer powerful pattern-based control.
A crate is the smallest unit of compilation in Rust, representing a library or an executable. It's the root of the module tree and contains all compiled code.
Rust has various data types, categorized into scalar (integers, floats, booleans, characters) and compound (tuples, arrays). They define the kind of value a variable can hold.
The `Deref` trait allows smart pointers to behave like regular references by customizing the behavior of the dereference operator (`*`). It enables implicit dereferencing.
Distroless is a project pioneered by Google that builds minimal Docker container images containing only your application and its direct runtime dependencies.
Rust's documentation system uses markdown comments (`///` and `//!`) directly in the source code. `cargo doc` generates HTML documentation for crates and modules.
The `Drop` trait allows you to customize what happens when a value is about to go out of scope. It's used for cleanup logic, like freeing resources or closing files.
Enums (enumerations) are custom data types that represent a value that can be one of a few possible variants. They are powerful for modeling states or different kinds of data.
Rust uses `Result<T, E>` for recoverable errors and `panic!` for unrecoverable errors. `Option<T>` handles cases where a value might be absent, encouraging explicit error management.
FFI allows Rust code to interact with code written in other languages, typically C. It involves defining external functions and structures with `extern "C"` blocks.
Functions are blocks of code that perform a specific task and can be called by name. They take parameters as input and can return a value as output.
Generics allow writing code that works with multiple types without duplicating code. They enable functions, structs, and enums to be defined with placeholder types.
A HashMap<K, V> is a collection type provided by Rust's standard library (std::collections::HashMap) that stores data as key-value pairs. It uses a hashing function to map keys to values, allowing for very fast data retrieval, insertion, and deletion.
A HashSet<T> in Rust is a collection that stores a group of unique values of type T without any duplicates. It is part of the standard library under std::collections::HashSet.
An `impl` (implementation) block is used to define methods for a specific type, or to implement a trait for a type. It associates functions with data structures.
Iterators provide a way to process sequences of items. They implement the `Iterator` trait, offering methods for common operations like mapping, filtering, and consuming items.
Lifetimes are a Rust compiler feature that ensures references remain valid for as long as they are needed. They prevent dangling references by ensuring data outlives its references.
A LinkedList<T> in Rust is a doubly-linked list provided by the standard library under std::collections::LinkedList. Unlike languages like Java or C++, where linked lists are often the go-to default for sequences, linked lists are rarely used in idiomatic Rust due to ownership rules and performance characteristics.
Macros are a form of metaprogramming that write code that writes other code. They expand into regular Rust code at compile time, reducing boilerplate and extending syntax.
Match expressions allow comparing a value against a series of patterns and executing different code branches based on the first match. They are exhaustive, ensuring all cases are handled.
Modules are used to organize code within a crate into logical units. They control the visibility of items (functions, structs, enums) and prevent naming conflicts.
Mutability in Rust refers to whether a variable's value can be changed after it's bound. Variables are immutable by default and must be explicitly declared with `mut` to be mutable.
Ownership is Rust's core memory management system, ensuring memory safety without a garbage collector. Each value has a single owner, and when the owner goes out of scope, the value is dropped.
Pattern matching is a powerful control flow construct using `match` expressions. It allows comparing a value against a series of patterns and executing code based on the first match.
Rayon is a popular data-parallelism library for Rust. It turns sequential computations into parallel executed tasks with minimal code changes. By leveraging Rust's safety guarantees, Rayon makes it easy to achieve safe, high-performance concurrency without data races.
Rust is a multi-paradigm, high-performance systems programming language designed for speed, memory safety, and safe concurrency. Developed initially at Mozilla Research, Rust empowers developers to build reliable and efficient software by catching common memory bugs at compile time rather than runtime.
Smart pointers are data structures that act like pointers but have additional metadata and capabilities. Examples include `Box`, `Rc`, and `Arc`, which manage heap data and ownership.
`String` is a growable, heap-allocated, UTF-8 encoded string type. `&str` (string slice) is an immutable reference to a sequence of UTF-8 bytes, often pointing into a `String` or static memory.
Structs (structures) are custom data types that group related data together into a single unit. They allow you to create meaningful data types by combining fields.
Rust provides built-in support for unit, integration, and documentation tests. Tests are written as functions annotated with `#[test]` and run with `cargo test`.
Traits define shared behavior that types can implement. They are similar to interfaces in other languages, enabling polymorphism and defining contracts for types.
Tuples are a compound data type that group together a fixed number of values of different types. They are immutable and their elements can be accessed by index.
Type inference is Rust's ability to deduce the type of a variable or expression automatically at compile time. This reduces the need for explicit type annotations.
Unsafe Rust allows bypassing some of Rust's safety guarantees, such as dereferencing raw pointers or calling `unsafe` functions. It's used for FFI or performance-critical code, requiring programmer vigilance.
Variables are named storage locations for values. In Rust, variables are immutable by default and require the `mut` keyword for modification after initial assignment.
VecDeque (short for vector double-ended queue) is a collection type provided by Rust's standard library (std::collections::VecDeque).