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::allocMemory allocation APIs. For advanced users.Memory Management
std::anyUtilities for dynamic typing or type reflection. Home of Any↗. Use for plugins, extensibility, scripting. Advanced.Development Tools: Cargo Plugins Scripting
std::archSIMD and vendor intrinsics module. Advanced topic.std::simd↗ module
std::arrayUtilities for the array primitive type (https://doc.rust-lang.org/std/primitive.array.html)↗.Data Structures, Vectors, Slices
std::asciiOperations on ASCII strings and characters. You may use escape_defaultEncoding
std::backtraceSupport for capturing a stack backtrace of an OS thread.Error Handling
std::borrowA module for working with borrowed data. Home of Borrow↗ and BorrowMut↗.Borrow, Ownership and Borrowing
std::boxedThe Box<T>↗ type for heap allocation.Box
std::cellShareable mutable containers. Home of RefCell<T>↗.Interior Mutability
std::charUtilities for the char↗ primitive type.
std::cloneThe Clone↗ trait for types that cannot be implicitly copied.ToOwned↗, Cow
std::cmpUtilities for comparing and ordering values. Home of PartialEq↗, Eq↗, PartialOrd↗, Ord↗.Equality and Ordering, Algorithms, Sorting
std::collectionsCollection types. Home of HashMap↗, HashSet↗ and others.HashMap, Data Structures
std::convertTraits for conversions between types: AsRef, From↗ and others.AsRef
std::defaultThe Default↗ trait for types with a default value.Conversion Traits,
std::envInspection and manipulation of the process's environment.Environment Variables
std::errorError↗ Interfaces.Error Handling
std::f32Constants for the f32 single-precision floating point type.Data Types
std::f64Constants for the f64 double-precision floating point type.Data Types
std::ffiUtilities related to FFI bindings. Home of OsString↗ and CString↗.Other Strings
std::fmtUtilities for formatting and printing Strings. Home of the Write↗ trait.Strings, format!↗ macro
std::fsFilesystem manipulation operations. Home of File↗ and many useful functions.Filesystem, Directories
std::futureAsynchronous basic functionality. Home of the Future↗ trait.Async
std::hashGeneric hashing support. Home of the Hash↗ trait.Cryptography, Data Structures
std::hintHints to compiler that affects how code should be emitted or optimized. Advanced.Benchmarking
std::ioTraits, helpers, and type definitions for core I/O functionality. Home of the Read↗ and Write↗ traits and useful functions.Read & Write from Files
std::iterComposable external iteration. Home of the Iterator↗ and IntoIterator↗ traits.Iterators
std::markerPrimitive traits and types representing basic properties of types. Home of Send↗, Sync↗, Sized↗, Copy↗, and PhantomData↗.Send & Sync, Ownership & Borrowing, Derive
std::memBasic functions for dealing with memory, such as drop()↗.Memory Management
std::netNetworking primitives for TCP/UDP communication. Home of IpAddr↗ and TcpListener↗.Network Programming
std::numAdditional functionality for numerics. Home of NonZero↗, Saturating↗, and Wrapping↗.Data Types, Mathematics
std::opsOverloadable operators, e.g., Add↗, Mul↗ and Index↗. Also home of Fn↗ and related traits; Deref↗ and Drop↗.Ops, Drop, Closures, Memory Management
std::optionOptional values via Option↗.Option
std::osOS-specific functionality.OS
std::panicPanic support in the standard library.Error Handling
std::pathCross-platform path manipulation with PathBuf↗ and PathFilesystem
std::pinTypes that pin data to a location in memory, via Pin↗.Pin, Rust-specific Patterns
std::preludeThe prelude that Rust automatically imports into every Rust program.Code Organization
std::primitiveThis module reexports the primitive types to allow usage that is not possibly shadowed by other declared types.Data Types
std::processA module for working with processes. Home of Command↗ and exit()↗.External Commands
std::ptrManually manage memory through raw pointers, e.g. NotNull↗ and many unsafe functions. Advanced topic.Ownership & Borrowing
std::rcSingle-threaded reference-counting pointers. 'Rc' stands for "Reference Counted". See Rc↗.Reference Counting
std::resultError handling with the Result↗ type.Result
std::sliceUtilities for the slice↗ primitive type.Slices
std::strUtilities for the str↗ primitive type.Slices, String
std::stringA UTF-8–encoded, growable String↗.String
std::syncUseful synchronization primitives: Arc↗, Mutex↗, LazyLock↗.Concurrency, Smart Pointers, Sync
std::taskTypes and Traits for working with asynchronous tasks. For advanced users.Asynchronous
std::threadNative threads with Thread↗.Explicit Thread
std::timeTemporal quantification with Duration↗ and Instant↗.Date & Time
std::vecA 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.

Option

Result

Default

Equality and Ordering

Smart Pointers

Box

Reference Counting: Rc, Arc

Interior Mutability: RefCell, Cell

RecipeCrates
Cellstd
RefCellstd
OnceCellstd

Clone-On-Write: Cow

Pin

Drop

Conversion Traits: From, Into, TryFrom, TryInto

AsRef

Borrow

Automatic Trait Derivation

Overloading Operators

Dynamic Typing