@@ -8,3 +8,78 @@ It is automatically used in every module.
88It is not possible to disable standard library prelude importing.
99This means that items from the prelude are always in scope without explicit imports,
1010which is why you can use types like `Option` , `Result` , and common traits without importing them.
11+
12+ == Edition-based Preludes
13+
14+ Cairo has five compiler editions that map to three prelude definitions.
15+ The edition is selected via the `edition` field in your project's `Scarb.toml`.
16+
17+ - `core::prelude::v2024_07` — the modern prelude, used by editions `v2024_07` and `v2025_12`
18+ - `core::prelude::v2023_10` — intermediate edition, used by editions `v2023_10` and `v2023_11`
19+ - `core::prelude::v2023_01` — the legacy prelude
20+
21+ Each successive prelude is more conservative, exporting only the most commonly needed items.
22+
23+ == Key Items in the Prelude
24+
25+ The following items are available in both prelude editions (the modern `v2024_07` prelude
26+ exports exactly these):
27+
28+ === Types
29+
30+ - `Array`, `Span` — dynamic arrays and their read-only views
31+ - `Box` — heap-allocated values
32+ - `ByteArray` — variable-length byte strings
33+ - `bytes31` — packed 31-byte value
34+ - `Nullable` — nullable pointer type
35+ - `Option` (with `Some`, `None`) — optional values
36+ - `Result` (with `Ok`, `Err`) — error handling
37+ - `NonZero` — wrapper guaranteeing a non-zero value
38+ - `felt252`, `bool`, `usize` — primitive types
39+ - `u8`, `u16`, `u32`, `u64`, `u128`, `u256` — unsigned integers
40+ - `i8`, `i16`, `i32`, `i64`, `i128` — signed integers
41+
42+ === Traits
43+
44+ - `Add`, `Sub`, `Mul`, `Div`, `Rem`, `DivRem`, `Neg`, `Not` — arithmetic operations
45+ - `Copy`, `Drop`, `Clone` — value semantics
46+ - `Default` — default values
47+ - `Destruct`, `PanicDestruct` — destruction
48+ - `Felt252DictValue` — dictionary value support
49+ - `Into`, `TryInto` — type conversions
50+ - `PartialEq`, `PartialOrd` — comparison
51+ - `Serde` — serialization
52+ - `Deref` — dereference operator
53+
54+ === Other Items
55+
56+ - `Felt252DictTrait` — dictionary operations
57+ - `ArrayTrait`, `SpanTrait`, `ToSpanTrait` — array operations
58+ - `BoxTrait`, `ByteArrayTrait`, `Bytes31Trait` — type-specific operations
59+ - `OptionTrait`, `ResultTrait`, `NullableTrait` — unwrapping and chaining
60+ - `Panic`, `PanicResult`, `panic` — panic handling
61+ - `FromIterator`, `IntoIterator`, `Iterator` — iteration
62+ - `assert` — assertion macro
63+ - `starknet`, `System` — Starknet access (under `corelib-internal-use` feature gate)
64+
65+ == Additional Items in Older Editions
66+
67+ The `v2023_10` and `v2023_01` preludes additionally export:
68+
69+ - `BitAnd`, `BitOr`, `BitXor`, `BitNot` — bitwise operation traits
70+ - `Felt252Dict`, `SquashedFelt252Dict` — dictionary types
71+ - `Pedersen`, `Poseidon` — hash builtins
72+ - `GasBuiltin`, `Bitwise`, `RangeCheck`, `SegmentArena` — VM builtins
73+ - `StoragePointerReadAccess`, `StoragePointerWriteAccess`, `StorageMapReadAccess`,
74+ `StorageMapWriteAccess` — Starknet storage access traits
75+ - Deprecated `AddEq`, `SubEq`, `MulEq`, `DivEq`, `RemEq` — replaced by `core::ops::*Assign`
76+ - Deprecated `Index`, `IndexView` — replaced by `core::ops::index::*`
77+ - `keccak`, `math`, `to_byte_array` — utility modules
78+
79+ The `v2023_01` prelude further exports low-level conversion impls (e.g.,
80+ `Felt252TryIntoU128`, `U128IntoFelt252`), EC point types, and additional builtins.
81+
82+ == See also
83+
84+ - xref:../../language_semantics/pages/linear-types.adoc[Linear types] — `Copy`, `Drop`, and `Destruct` semantics
85+ - xref:felt252dict-type.adoc[Felt252Dict] — Dictionary usage and `Felt252DictValue`
0 commit comments