Standard Library

The Standard Library provides essential functionality for Rust programs and includes modules for memory management, concurrency, collections, and more. The Standard Library is automatically included in every Rust project.

We listed below the (stable) modules of the Standard Library, highlighted the most important modules, and listed key types. Consult the complete documentation for the Standard Library↗ as well.

ModulesDescriptionSee Also
std::alloc↗Memory allocation APIs. For advanced users.Memory Management
std::any↗Utilities for dynamic typing or type reflection. Home of Any↗. Use for plugins, extensibility, scripting. Advanced.Development Tools: Cargo Plugins Scripting
std::arch↗SIMD and vendor intrinsics module. Advanced topic.std::simd↗ module
std::array↗Utilities for the array primitive type [T; N].Data Structures, Vectors, Slices
std::ascii↗Operations on ASCII strings and characters. You may use escape_default↗Encoding
std::backtrace↗Support for capturing a stack backtrace of an OS thread.Error Handling
std::borrow↗A module for working with borrowed data. Home of Borrow↗ and BorrowMut↗.Borrow, Ownership and Borrowing
std::boxed↗The Box<T>↗ type for heap allocation.Box
std::cell↗Shareable mutable containers. Home of RefCell<T>↗.Interior Mutability
std::char↗Utilities for the char↗ primitive type.
std::clone↗The Clone↗ trait for types that cannot be implicitly copied.ToOwned↗, Cow
std::cmp↗Utilities for comparing and ordering values. Home of PartialEq↗, Eq↗, PartialOrd↗, Ord↗.Equality and Ordering, Algorithms, Sorting
std::collections↗Collection types. Home of HashMap↗, HashSet↗ and others.HashMap, Data Structures
std::convert↗Traits for conversions between types: AsRef↗, From↗ and others.AsRef
std::default↗The Default↗ trait for types with a default value.Conversion Traits,
std::env↗Inspection and manipulation of the process's environment.Environment Variables
std::error↗Error↗ Interfaces.Error Handling
std::f32↗Constants for the f32 single-precision floating point type.Data Types
std::f64↗Constants for the f64 double-precision floating point type.Data Types
std::ffi↗Utilities related to FFI bindings. Home of OsString↗ and CString↗.Other Strings
std::fmt↗Utilities for formatting and printing Strings. Home of the Write↗ trait.Strings, format!↗ macro
std::fs↗Filesystem manipulation operations. Home of File↗ and many useful functions.Filesystem, Directories
std::future↗Asynchronous basic functionality. Home of the Future↗ trait.Async
std::hash↗Generic hashing support. Home of the Hash↗ trait.Cryptography, Data Structures
std::hint↗Hints to compiler that affects how code should be emitted or optimized. Advanced.Benchmarking
std::io↗Traits, helpers, and type definitions for core I/O functionality. Home of the Read↗ and Write↗ traits and useful functions.Read & Write from Files
std::iter↗Composable external iteration. Home of the Iterator↗ and IntoIterator↗ traits.Iterators
std::marker↗Primitive traits and types representing basic properties of types. Home of Send↗, Sync↗, Sized↗, Copy↗, and PhantomData↗.Send & Sync, Ownership & Borrowing, Derive
std::mem↗Basic functions for dealing with memory, such as drop↗.Memory Management
std::net↗Networking primitives for TCP/UDP communication. Home of IpAddr↗ and TcpListener↗.Network Programming
std::num↗Additional functionality for numerics. Home of NonZero↗, Saturating↗, and Wrapping↗.Data Types, Mathematics
std::ops↗Overloadable operators, e.g., Add↗, Mul↗ and Index↗. Also home of Fn↗ and related traits; Deref↗ and Drop↗.Ops, Drop, Closures, Memory Management
std::option↗Optional values via Option↗.Option
std::os↗OS-specific functionality.OS
std::panic↗Panic support in the standard library.Error Handling
std::path↗Cross-platform path manipulation with PathBuf↗ and Path↗Filesystem
std::pin↗Types that pin data to a location in memory, via Pin↗.Pin, Rust-specific Patterns
std::prelude↗The prelude that Rust automatically imports into every Rust program.Code Organization
std::primitive↗This module reexports the primitive types to allow usage that is not possibly shadowed by other declared types.Data Types
std::process↗A module for working with processes. Home of Command↗ and exit()↗.External Commands
std::ptr↗Manually manage memory through raw pointers, e.g. NotNull↗ and many unsafe functions. Advanced topic.Ownership & Borrowing
std::rc↗Single-threaded reference-counting pointers. 'Rc' stands for "Reference Counted". See Rc↗.Reference Counting
std::result↗Error handling with the Result↗ type.Result
std::slice↗Utilities for the slice↗ primitive type.Slices
std::str↗Utilities for the str↗ primitive type.Slices, String
std::string↗A UTF-8–encoded, growable String↗.String
std::sync↗Useful synchronization primitives: Arc↗, Mutex↗, LazyLock↗.Concurrency, Smart Pointers, Sync
std::task↗Types and Traits for working with asynchronous tasks. For advanced users.Asynchronous
std::thread↗Native threads with Thread↗.Explicit Thread
std::time↗Temporal quantification with Duration↗ and Instant↗.Date & Time
std::vec↗A contiguous growable array type with heap-allocated contents, written Vec<T>↗.Vectors

The following covers portions of the Rust Standard Library that are not otherwise covered by another chapter: core types like Option↗, Result↗; smart pointers; and traits for conversions.

Optional Values: Option

Recoverable Error Handling: Result

Default Values: Default

Value Comparison: Equality and Ordering

Smart Pointers

Heap Storage with Box

Reference Counting: Rc, Arc

Interior Mutability: RefCell, Cell, OnceCell

Clone-on-Write: Cow

Memory Address Pinning: Pin

Resource Cleanup: Drop

Conversion Traits: From, Into, TryFrom, TryInto

Reference-to-reference Conversion: AsRef

Borrowed Types: Borrow

Automatic Trait Derivation: derive

Operators

Dynamic Typing: Any