On this page
rust/builtins
Prev: rust | Up: rust | Next: std
Rel: rust/std, Ownership, Borrowing & Lifetimes
Ref: Rust Standard Library Prelude
Tags: #public #prog #rust #builtins #index
Overview
Core Rust language primitives, keywords, and std::prelude types/traits available in every module with zero use imports.
Core (#tier/core)
- `Option` (Prelude Enum) — Replaces
nullwith an explicit type-checked sum type representing presence (Some(T)) or absence (None). - `Result` (Prelude Enum) — Explicit recoverable error handling without exceptions; propagates cleanly via the
?operator. - `Vec` (Prelude Type) — Contiguous, growable heap-allocated array (
ptr,len,cap) with amortized $O(1)$ push. - `String` (Prelude Type) — Heap-allocated, growable, guaranteed-valid UTF-8 string (essentially a
Vec<u8>with UTF-8 invariant). - `str` (Primitive Slice) — Fat pointer
(ptr, byte_len)borrowing a valid UTF-8 sequence (string literals have type&'static str). - `Copy` (Marker Trait) — Marks stack-only bitwise-copyable types so assignment copies instead of moving ownership.
- `Clone` (Prelude Trait) — Explicitly duplicates a value (potentially performing a heap allocation).
- `Drop` (Prelude Trait (RAII)) — Deterministic destructor automatically invoked when an owned value goes out of scope (in reverse declaration order).
- `Iterator` (Prelude Trait) — Zero-cost lazy iteration protocol powering
forloops and combinators (.map(),.filter(),.fold(),.collect()). - `From` (Prelude Trait) — Infallible value-to-value conversion; implementing
From<A> for Bautomatically providesInto<B> for Aand enables?error conversion. - `match` (Language Expression) — Exhaustive structural pattern matching over enums, tuples, slices, ranges, and guards.
Standard (#tier/standard)
- `Send` (Auto Marker Trait) — Marks types safe to transfer ownership across OS thread boundaries.
- `Sync` (Auto Marker Trait) — Marks types safe to share immutable references (
&T) across multiple threads simultaneously (T: Synciff&T: Send).
Specialized (#tier/specialized)
- `unsafe` (Language Keyword) — Opts into 5 low-level operations (dereferencing raw pointers, calling
unsafe fn/FFI, mutable statics, unsafe traits, union fields) while keeping the borrow checker active. - `macro_rules` (Declarative Macro) — Hygienic token-tree macro system for compile-time code generation without runtime overhead.
Legacy / Avoid (#tier/legacy)
- `try!` (Pre-2018 Macro) — Legacy Rust 1.0 error-propagation macro superseded by the built-in
?operator. Prefer Result & ? operator.
Linked from
- tuts/rust
- tuts/rust/builtins/Clone
- tuts/rust/builtins/Copy
- tuts/rust/builtins/Drop
- tuts/rust/builtins/From
- tuts/rust/builtins/Iterator
- tuts/rust/builtins/macro_rules
- tuts/rust/builtins/match
- tuts/rust/builtins/Option
- tuts/rust/builtins/Result
- tuts/rust/builtins/Send
- tuts/rust/builtins/str
- tuts/rust/builtins/String
- tuts/rust/builtins/Sync
- tuts/rust/builtins/try_macro
- tuts/rust/builtins/unsafe
- tuts/rust/builtins/Vec
- tuts/rust/std
- tuts/rust/std/collections
- tuts/rust/std/collections/BinaryHeap
- tuts/rust/std/collections/BTreeMap
- tuts/rust/std/collections/HashMap
- tuts/rust/std/collections/HashSet
- tuts/rust/std/collections/VecDeque
- tuts/rust/std/error_and_fmt
- tuts/rust/std/error_and_fmt/Display
- tuts/rust/std/error_and_fmt/Error
- tuts/rust/std/error_and_fmt/format
- tuts/rust/std/ffi
- tuts/rust/std/ffi/CString
- tuts/rust/std/ffi/extern_C
- tuts/rust/std/io_and_fs
- tuts/rust/std/io_and_fs/BufReader
- tuts/rust/std/io_and_fs/File
- tuts/rust/std/io_and_fs/PathBuf
- tuts/rust/std/io_and_fs/Read
- tuts/rust/std/smart_pointers
- tuts/rust/std/smart_pointers/Arc
- tuts/rust/std/smart_pointers/Box
- tuts/rust/std/smart_pointers/Cow
- tuts/rust/std/smart_pointers/Rc
- tuts/rust/std/smart_pointers/RefCell
- tuts/rust/std/sync
- tuts/rust/std/sync/AtomicUsize
- tuts/rust/std/sync/mpsc
- tuts/rust/std/sync/Mutex
- tuts/rust/std/sync/OnceLock
- tuts/rust/std/sync/RwLock
Related notes
- tuts/rust Linked here; links to this page; shared tags: #index, #prog, #rust
- tuts/rust/builtins/Clone Linked here; links to this page; shared tags: #builtins, #prog, #rust
- tuts/rust/builtins/Copy Linked here; links to this page; shared tags: #builtins, #prog, #rust
- tuts/rust/builtins/Drop Linked here; links to this page; shared tags: #builtins, #prog, #rust
- tuts/rust/builtins/From Linked here; links to this page; shared tags: #builtins, #prog, #rust
- tuts/rust/builtins/Iterator Linked here; links to this page; shared tags: #builtins, #prog, #rust
- tuts/rust/builtins/macro_rules Linked here; links to this page; shared tags: #builtins, #prog, #rust
- tuts/rust/builtins/match Linked here; links to this page; shared tags: #builtins, #prog, #rust
- tuts/rust/builtins/Option Linked here; links to this page; shared tags: #builtins, #prog, #rust
- tuts/rust/builtins/Result Linked here; links to this page; shared tags: #builtins, #prog, #rust