@@ -18,9 +18,21 @@ There are several different preludes:
18
18
19
19
## Standard library prelude
20
20
21
- The standard library prelude includes names from the [ ` std::prelude::v1 ` ]
22
- module. If the [ ` no_std ` attribute] is used, then it instead uses the names
23
- from the [ ` core::prelude::v1 ` ] module.
21
+ Each crate has a standard library prelude, which consists of the names from a single standard library module.
22
+ The module used depends on the crate's edition, and on whether the [ ` no_std ` attribute] is applied to the crate:
23
+
24
+ Edition | ` no_std ` not applied | ` no_std ` applied
25
+ --------| --------------------------- | ----------------------------
26
+ 2015 | [ ` std::prelude::rust_2015 ` ] | [ ` core::prelude::rust_2015 ` ]
27
+ 2018 | [ ` std::prelude::rust_2018 ` ] | [ ` core::prelude::rust_2018 ` ]
28
+ 2021 | [ ` std::prelude::rust_2021 ` ] | [ ` core::prelude::rust_2021 ` ]
29
+
30
+
31
+ > ** Note** :
32
+ >
33
+ > [ ` std::prelude::rust_2015 ` ] and [ ` std::prelude::rust_2018 ` ] have the same contents as [ ` std::prelude::v1 ` ] .
34
+ >
35
+ > [ ` core::prelude::rust_2015 ` ] and [ ` core::prelude::rust_2018 ` ] have the same contents as [ ` core::prelude::v1 ` ] .
24
36
25
37
## Extern prelude
26
38
@@ -63,15 +75,13 @@ By default, the standard library is automatically included in the crate root
63
75
module . The [`std `] crate is added to the root , along with an implicit
64
76
[`macro_use ` attribute ] pulling in all macros exported from `std ` into the
65
77
[`macro_use ` prelude ]. Both [`core `] and [`std `] are added to the [extern
66
- prelude ]. The [standard library prelude ] includes everything from the
67
- [`std :: prelude :: v1 `] module .
78
+ prelude ].
68
79
69
80
The * `no_std ` [attribute ]* may be applied at the crate level to prevent the
70
81
[`std `] crate from being automatically added into scope . It does three things :
71
82
72
83
* Prevents `std ` from being added to the [extern prelude ](#extern - prelude ).
73
- * Uses [`core :: prelude :: v1 `] in the [standard library prelude ] instead of
74
- [`std :: prelude :: v1 `].
84
+ * Affects which module is used to make up the [standard library prelude ] (as described above ).
75
85
* Injects the [`core `] crate into the crate root instead of [`std `], and pulls
76
86
in all macros exported from `core ` in the [`macro_use ` prelude ].
77
87
@@ -129,14 +139,20 @@ This attribute does not affect the [language prelude].
129
139
130
140
[`alloc`]: .. / .. / alloc/ index. html
131
141
[`Box`]: .. / .. / std/ boxed/ struct . Box. html
132
- [`core:: prelude:: v1`]: .. / .. / core/ prelude/ index. html
142
+ [`core:: prelude:: v1`]: .. / .. / core/ prelude/ v1/ index. html
143
+ [`core:: prelude:: rust_2015`]: .. / .. / core/ prelude/ rust_2015/ index. html
144
+ [`core:: prelude:: rust_2018`]: .. / .. / core/ prelude/ rust_2018/ index. html
145
+ [`core:: prelude:: rust_2021`]: .. / .. / core/ prelude/ rust_2021/ index. html
133
146
[`core`]: .. / .. / core/ index. html
134
147
[`extern crate `]: .. / items/ extern - crates. md
135
148
[`macro_use` attribute]: .. / macros- by- example. md#the- macro_use- attribute
136
149
[`macro_use` prelude]: #macro_use- prelude
137
150
[`no_std` attribute]: #the- no_std- attribute
138
151
[`no_std` attribute]: #the- no_std- attribute
139
- [`std:: prelude:: v1`]: .. / .. / std/ prelude/ index. html
152
+ [`std:: prelude:: v1`]: .. / .. / std/ prelude/ v1/ index. html
153
+ [`std:: prelude:: rust_2015`]: .. / .. / std/ prelude/ rust_2015/ index. html
154
+ [`std:: prelude:: rust_2018`]: .. / .. / std/ prelude/ rust_2018/ index. html
155
+ [`std:: prelude:: rust_2021`]: .. / .. / std/ prelude/ rust_2021/ index. html
140
156
[`std`]: .. / .. / std/ index. html
141
157
[`test`]: .. / .. / test/ index. html
142
158
[attribute]: .. / attributes. md
0 commit comments