Module std

The Rust standard library

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).

Standard library injection and the Rust prelude

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::*;

Modules

ascii

Operations on ASCII strings and characters.

at_vec

Managed vectors

bool

The bool module contains useful code to help work with boolean values.

borrow

Borrowed pointer utilities

c_str

C-string manipulation and management

cast

Unsafe casting functions

cell

A mutable, nullable memory location

char

Utilities for manipulating the char type

clone

The Clone trait for types that cannot be "implicitly copied"

cmath
cmp

The Ord and Eq comparison traits

comm

Message passing

condition

Condition handling

container

Container traits

default

The Default trait

either

A type that represents one of two alternatives

f32

Operations and constants for f32

f64

Operations and constants for f64

float

Operations and constants for float

fmt

The Formatting Module

from_str

The trait for types that can be created from strings

hash

Implementation of SipHash 2-4

hashmap

An unordered map and set type implemented as hash tables

i16

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 external iterators

kinds

The kind traits

libc

Bindings for the C standard library and other platform libraries

local_data

Task local data management

logging

Logging

managed

Operations on managed box types

num

Numeric traits and functions for generic mathematics.

ops

Traits for the built-in operators

option

Operations on the ubiquitous Option type.

os

Higher-level interfaces to libc::* functions and operating system services.

owned

Operations on unique pointer types

path

Cross-platform file path handling

prelude

Many programming languages have a 'prelude': a particular subset of the libraries that come with the language. Every program imports the prelude by default.

ptr

Unsafe pointer utility functions

rand

Random number generation.

reflect

Runtime type reflection

repr

More runtime type reflection

result

A type representing either success or failure

routine

Routines are like closures except that they own their arguments and can only run once.

rt

The Rust Runtime, including the task scheduler and I/O

run

Process spawning.

select
send_str

SendStr definition and trait implementations

str

String manipulation

sys

Misc low level stuff

task

Task management.

to_bytes

The ToBytes and IterBytes traits

to_str

The ToStr trait for converting to strings

trie

An ordered map and set for integer keys implemented as a radix trie

tuple

Operations on tuples

u16

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

unicode
unit

Functions for the unit type.

util

Miscellaneous helpers for common patterns.

vec

Vector manipulation