Rust stdlib: Intro

Basic Types

  • array: A fixed-size array, denoted [T; N], for the element type, T, and the non-negative compile-time constant size, N.
  • bool: The boolean type.
  • char: A character type.
  • f32: The 32-bit floating point type.
  • f64: The 64-bit floating point type.
  • fn: Function pointers, like fn(usize) -> bool.
  • i8: The 8-bit signed integer type.
  • i16: The 16-bit signed integer type.
  • i32: The 32-bit signed integer type.
  • i64: The 64-bit signed integer type.
  • i128: The 128-bit signed integer type.
  • isize: The pointer-sized signed integer type.
  • pointer: Raw, unsafe pointers, *const T, and *mut T.
  • reference: References, both shared and mutable.
  • slice: A dynamically-sized view into a contiguous sequence, [T]. Contiguous here means that elements are laid out so that every element is the same distance from its neighbors.
  • str: String slices.
  • tuple: A finite heterogeneous sequence, (T, U, ..).
  • u8: The 8-bit unsigned integer type.
  • u16: The 16-bit unsigned integer type.
  • u32: The 32-bit unsigned integer type.
  • u64: The 64-bit unsigned integer type.
  • unit: The () type, also called "unit".
  • usize: The pointer-sized unsigned integer type.
  • primitive: This module reexports the primitive types to allow usage that is not possibly shadowed by other declared types.

Modules

Basic Types

  • array: Implementations of things like Eq for fixed-length arrays up to a certain length. Eventually, we should be able to generalize to all lengths.
  • f32: This module provides constants which are specific to the implementation of the f32 floating point data type.
  • f64: This module provides constants which are specific to the implementation of the f64 floating point data type.
  • i8: The 8-bit signed integer type.
  • i16: The 16-bit signed integer type.
  • i32: The 32-bit signed integer type.
  • i64: The 64-bit signed integer type.
  • i128: The 128-bit signed integer type.
  • isize: The pointer-sized signed integer type.
  • num: Additional functionality for numerics.
  • u8: The 8-bit unsigned integer type.
  • u16: The 16-bit unsigned integer type.
  • u32: The 32-bit unsigned integer type.
  • u64: The 64-bit unsigned integer type.
  • u128: The 128-bit unsigned integer type.
  • usize: The pointer-sized unsigned integer type.

Error handling

  • error: Traits for working with Errors.
  • panic: Panic support in the standard library.
  • result: Error handling with the Result type.

Text

  • ascii: Operations on ASCII strings and characters.
  • char: A character type.
  • fmt: Utilities for formatting and printing Strings.
  • str: Unicode string slices.
  • string: A UTF-8 encoded, growable string.

Containers

  • cell: Shareable mutable containers.
  • collections: Collection types.
  • hash: Generic hashing support.
  • iter: Composable external iteration.
  • vec: A contiguous growable array type with heap-allocated contents, written Vec<T>.

Memory

  • alloc: Memory allocation APIs
  • borrow: A module for working with borrowed data.
  • boxed: A pointer type for heap allocation.
  • mem: Basic functions for dealing with memory.
  • pin: Types that pin data to its location in memory.
  • ptr: Manually manage memory through raw pointers.
  • rc: Single-threaded reference-counting pointers. 'Rc' stands for 'Reference Counted'.
  • slice: A dynamically-sized view into a contiguous sequence, [T].

Types

  • any: This module implements the Any trait, which enables dynamic typing of any 'static type through runtime reflection.
  • clone: The Clone trait for types that cannot be 'implicitly copied'.
  • convert: Traits for conversions between types.
  • default: The Default trait for types which may have meaningful default values.
  • marker: Primitive traits and types representing basic properties of types.
  • ops: Overloadable operators.
  • option: Optional values.

Interacting with the World

  • env: Inspection and manipulation of the process's environment.
  • ffi: Utilities related to FFI bindings.
  • fs: Filesystem manipulation operations.
  • io: Traits, helpers, and type definitions for core I/O functionality.
  • net: Networking primitives for TCP/UDP communication.
  • os: OS-specific functionality.
  • path: Cross-platform path manipulation.
  • process: A module for working with processes.
  • time: Temporal quantification.

Concurrency

  • future: Asynchronous values.
  • sync: Useful synchronization primitives.
  • task: Types and Traits for working with asynchronous tasks.
  • thread: Native threads.

Misc

  • hint: Hints to compiler that affects how code should be emitted or optimized.
  • prelude: The Rust Prelude.

Macros

Assertions & Debugging

  • assert: Asserts that a boolean expression is true at runtime.
  • assert_eq: Asserts that two expressions are equal to each other (using PartialEq).
  • assert_ne: Asserts that two expressions are not equal to each other (using PartialEq).
  • dbg: Prints and returns the value of a given expression for quick and dirty debugging.
  • debug_assert: Asserts that a boolean expression is true at runtime.
  • debug_assert_eq: Asserts that two expressions are equal to each other.
  • debug_assert_ne: Asserts that two expressions are not equal to each other.

Source

  • column: Expands to the column number at which it was invoked.
  • file: Expands to the file name in which it was invoked.
  • include: Parses a file as an expression or an item according to the context.
  • include_bytes: Includes a file as a reference to a byte array.
  • include_str: Includes a utf8-encoded file as a string.
  • module_path: Expands to a string that represents the current module path.

Control Flow

  • compile_error: Causes compilation to fail with the given error message when encountered.
  • is_x86_feature_detected: A macro to test at runtime whether a CPU feature is available on x86/x86-64 platforms.
  • line: Expands to the line number on which it was invoked.
  • matches: Returns whether the given expression matches any of the given patterns.
  • panic: Panics the current thread.
  • todo: Indicates unfinished code.
  • unimplemented: Indicates unimplemented code by panicking with a message of "not implemented".
  • unreachable: Indicates unreachable code.

Configuration

  • cfg: Evaluates boolean combinations of configuration flags at compile-time.
  • env: Inspects an environment variable at compile time.
  • option_env: Optionally inspects an environment variable at compile time.

Data

  • thread_local: Declare a new thread local storage key of type std::thread::LocalKey.
  • vec: Creates a Vec containing the arguments.

Output

  • concat: Concatenates literals into a static string slice.
  • eprint: Prints to the standard error.
  • eprintln: Prints to the standard error, with a newline.
  • format: Creates a String using interpolation of runtime expressions.
  • format_args: Constructs parameters for the other string-formatting macros.
  • print: Prints to the standard output.
  • println: Prints to the standard output, with a newline.
  • stringify: Stringifies its arguments.
  • write: Writes formatted data into a buffer.
  • writeln: Write formatted data into a buffer, with a newline appended.