The core library links to no upstream libraries, no system libraries, and no libc. It is platform-agnostic and minimal by design.
Overview
The core library is minimal: it isn’t even aware of heap allocation, nor does it provide concurrency or I/O. These things require platform integration, and this library is platform-agnostic.Key Characteristics
- No dependencies: Links to no external libraries
- Platform-agnostic: Works across all Rust targets
- Minimal footprint: Contains only essential primitives
- No allocation: Doesn’t require heap allocation
- No I/O: No input/output operations
Core Modules
Language Traits
borrow
Borrowing and ownership traits
clone
The Clone trait for explicit duplication
cmp
Comparison traits: Eq, PartialEq, Ord, PartialOrd
convert
Traits for type conversions: From, Into, TryFrom, TryInto
default
The Default trait for default values
marker
Marker traits: Send, Sync, Copy, Sized
ops
Operator overloading traits
error
The Error trait for error handling
Core Types and Primitives
option
Optional values with Option<T>
result
Error handling with Result<T, E>
array
Fixed-size arrays
slice
Dynamically-sized views into contiguous sequences
str
UTF-8 string slices
char
Unicode scalar values
Memory and Ownership
mem - Memory manipulation
mem - Memory manipulation
Core memory functions for working with values:
size_of,size_of_val- Size queriesswap,replace- Value manipulationdrop- Explicit destructor callsforget- Prevent destructors from running
ptr - Raw pointer manipulation
ptr - Raw pointer manipulation
Low-level pointer operations:
copy,copy_nonoverlapping- Memory copyingwrite,read- Pointer dereferencingnull,null_mut- Null pointer creation- Alignment and offset operations
cell - Interior mutability
cell - Interior mutability
Types for interior mutability patterns:
Cell<T>- Shared mutable containersRefCell<T>- Runtime-checked borrowingUnsafeCell<T>- Core primitive for interior mutability
pin - Pinning API
pin - Pinning API
Types for pinning data in memory:
Pin<P>- Pointer type that guarantees the pointed-to value won’t move- Essential for async/await and self-referential structures
Iteration
iter
Iterator traits and adaptors
async_iter
Async iteration (unstable)
Numeric Types
Integer types
Integer types
Signed and unsigned integers:
i8,i16,i32,i64,i128,isizeu8,u16,u32,u64,u128,usize
- Checked arithmetic
- Saturating arithmetic
- Wrapping arithmetic
- Bit manipulation
Floating-point types
Floating-point types
Floating-point numbers:
f16- 16-bit floating pointf32- 32-bit floating pointf64- 64-bit floating pointf128- 128-bit floating point
sqrt, sin, cos, etc.Formatting and Display
fmt - Formatting infrastructure
fmt - Formatting infrastructure
Core formatting traits:
Display- User-facing outputDebug- Programmer-facing outputBinary,Octal,Hex- Numeric formatting- Used by
println!,format!, etc.
Async and Concurrency
future
Asynchronous values with Future trait
task
Task management for async execution
sync
Atomic types and memory ordering
Other Core Functionality
any
Runtime type information
hash
Hashing traits
hint
Compiler hints
intrinsics
Compiler intrinsics
panic
Panic support
time
Duration type
Architecture Support
The
arch module provides platform-specific intrinsics and SIMD operations for various architectures including x86, ARM, RISC-V, and more.SIMD Support
Thesimd module provides portable SIMD (Single Instruction, Multiple Data) operations:
Usage Requirements
The core library is built on the assumption of a few existing symbols:Required memory routines
Required memory routines
memcpy,memmove,memset,memcmp,bcmp,strlen- These are core memory routines generated by Rust codegen backends
- Often provided by system libc or compiler-builtins crate
Panic handler
Panic handler
You must define a panic handler using Required for
#[panic_handler]:#![no_std] environments.Exception personality (optional)
Exception personality (optional)
rust_eh_personality is used by failure mechanisms. Often mapped to GCC’s personality function. Only called during unwinding.Common Patterns
Option and Result
Iterator Usage
Interior Mutability
Stability
The core library has been stable since Rust 1.6.0. It forms the immutable foundation of the Rust language and maintains strict backward compatibility.
Related Libraries
- alloc - Provides heap allocation primitives
- std - Full standard library built on core and alloc
- proc_macro - Procedural macro support