The Rust standard library is a group of interrelated modules defining the core language traits, operations on built-in data types, collections, platform abstractions, the task scheduler, runtime support for language features and other common functionality.
std
includes modules corresponding to each of the integer types, each of the floating point types, the bool
type, tuples, characters, strings (str
), vectors (vec
), managed boxes (managed
), owned boxes (owned
), and unsafe and borrowed pointers (ptr
, borrowed
). Additionally, std
provides pervasive types (option
and result
), task creation and communication primitives (task
, comm
), platform abstractions (os
and path
), basic I/O abstractions (io
), common traits (kinds
, ops
, cmp
, num
, to_str
), and complete bindings to the C standard library (libc
).
std
is imported at the topmost level of every crate by default, as if the first line of each crate was
extern mod std;
This means that the contents of std can be accessed from any context with the std::
path prefix, as in use std::vec
, use std::task::spawn
, etc.
Additionally, std
contains a prelude
module that reexports many of the most common types, traits and functions. The contents of the prelude are imported into every module by default. Implicitly, all modules behave as if they contained the following prologue:
use std::prelude::*;
ascii
- Operations on ASCII strings and characters.at_vec
- Managed vectorsbool
- The bool
module contains useful code to help work with boolean values.borrow
- Borrowed pointer utilitiescast
- Unsafe casting functionscell
- A mutable, nullable memory locationchar
- Utilities for manipulating the char typeclone
- The Clone trait for types that cannot be "implicitly copied"cmp
- The Ord
and Eq
comparison traitscomm
- Message passingcondition
- Condition handlingcontainer
- Container traitseither
- A type that represents one of two alternativesf32
- Operations and constants for f32
f64
- Operations and constants for f64
float
- Operations and constants for float
from_str
- The trait for types that can be created from stringshash
- Implementation of SipHash 2-4hashmap
- An unordered map and set type implemented as hash tablesi16
- Operations and constants for i16
i32
- Operations and constants for i32
i64
- Operations and constants for i64
i8
- Operations and constants for i8
int
- Operations and constants for int
io
- The io
module contains basic input and output routines.iter
- Composable internal iteratorsiterator
- Composable external iteratorskinds
- The kind traitslibc
- Bindings for the C standard library and other platform librarieslocal_data
- Task local data managementlogging
- Loggingmanaged
- Operations on managed box typesnil
- Functions for the unit type.num
- An interface for numeric typesops
- Traits for the built-in operatorsoption
- Operations on the ubiquitous Option
type.os
- Higher-level interfaces to libc::* functions and operating system services.owned
- Operations on unique pointer typespath
- Cross-platform file path handlingpipes
- Runtime support for message passing with protocol enforcement.prelude
- Many programming languages have a 'prelude': a particular subset of the libraries that come with the languageptr
- Unsafe pointer utility functionsrand
- Random number generation.reflect
- Runtime type reflectionrepr
- More runtime type reflectionresult
- A type representing either success or failurerun
- Process spawning.str
- String manipulationsys
- Misc low level stufftask
- Task management.to_bytes
- The ToBytes
and IterBytes
traitsto_str
- The ToStr
trait for converting to stringstrie
- An ordered map and set for integer keys implemented as a radix trietuple
- Operations on tuplesu16
- Operations and constants for u16
u32
- Operations and constants for u32
u64
- Operations and constants for u64
u8
- Operations and constants for u8
uint
- Operations and constants for uint
util
- Miscellaneous helpers for common patterns.vec
- Vectors