@@ -20,7 +20,7 @@ Here's a brief summary:
20
20
* Paths starting with ` :: ` must reference an external crate.
21
21
* A ` foo.rs ` and ` foo/ ` subdirectory may coexist; ` mod.rs ` is no longer needed
22
22
when placing submodules in a subdirectory.
23
- * ` use ` declarations take [ uniform paths] ( #uniform-paths ) .
23
+ * Paths in ` use ` declarations work the same as other paths.
24
24
25
25
These may seem like arbitrary new rules when put this way, but the mental
26
26
model is now significantly simplified overall. Read on for more details!
@@ -140,9 +140,6 @@ mod submodule {
140
140
// but in a submodule it requires a leading :: if not imported with `use`
141
141
let x = ::chrono::Utc::now();
142
142
}
143
-
144
- // unlike expressions, `use` paths were allowed to reference crates directly
145
- use chrono::Local;
146
143
}
147
144
```
148
145
@@ -162,9 +159,6 @@ mod submodule {
162
159
// crates may be referenced directly, even in submodules
163
160
let x = chrono::Utc::now();
164
161
}
165
-
166
- // `use` paths have the same path style
167
- use chrono::Local;
168
162
}
169
163
```
170
164
@@ -201,23 +195,22 @@ and the submodule is still `foo/bar.rs`. This eliminates the special
201
195
name, and if you have a bunch of files open in your editor, you can clearly
202
196
see their names, instead of having a bunch of tabs named ` mod.rs ` .
203
197
204
- # Uniform paths
198
+ ### ` use ` paths
205
199
206
200
![ Minimum Rust version: 1.32] ( https://img.shields.io/badge/Minimum%20Rust%20Version-1.32-brightgreen.svg )
207
201
208
- The uniform paths variant of Rust 2018 simplifies and unifies path handling
209
- compared to Rust 2015. In Rust 2015 , paths work differently in ` use `
210
- declarations than they do elsewhere. In particular, paths in ` use `
211
- declarations would always start from the crate root, while paths in other code
212
- implicitly started from the current scope. Those differences didn't have any
213
- effect in the top-level module, which meant that everything would seem
214
- straightforward until working on a project large enough to have submodules.
202
+ Rust 2018 simplifies and unifies path handling compared to Rust 2015. In Rust
203
+ 2015, paths work differently in ` use ` declarations than they do elsewhere. In
204
+ particular, paths in ` use ` declarations would always start from the crate
205
+ root, while paths in other code implicitly started from the current scope.
206
+ Those differences didn't have any effect in the top-level module, which meant
207
+ that everything would seem straightforward until working on a project large
208
+ enough to have submodules.
215
209
216
- In the uniform paths variant of Rust 2018, paths in ` use ` declarations and in
217
- other code almost always work the same way, both in the top-level module and
218
- in any submodule. You can use a relative path from the current scope, a path
219
- starting from an external crate name, or a path starting with ` crate ` ,
220
- ` super ` , or ` self ` .
210
+ In Rust 2018, paths in ` use ` declarations and in other code work the same way,
211
+ both in the top-level module and in any submodule. You can use a relative path
212
+ from the current scope, a path starting from an external crate name, or a path
213
+ starting with ` crate ` , ` super ` , or ` self ` .
221
214
222
215
Code that looked like this:
223
216
@@ -255,7 +248,7 @@ will look exactly the same in Rust 2018, except that you can delete the `extern
255
248
crate` line:
256
249
257
250
``` rust,ignore
258
- // Rust 2018 (uniform paths variant)
251
+ // Rust 2018
259
252
260
253
use futures::Future;
261
254
@@ -282,11 +275,10 @@ fn func() {
282
275
}
283
276
```
284
277
285
- With uniform paths, however, the same code will also work completely unmodified in
286
- a submodule:
278
+ The same code will also work completely unmodified in a submodule:
287
279
288
280
``` rust,ignore
289
- // Rust 2018 (uniform paths variant)
281
+ // Rust 2018
290
282
291
283
mod submodule {
292
284
use futures::Future;
0 commit comments