@@ -21,12 +21,12 @@ Here's a brief summary:
21
21
22
22
* ` extern crate ` is no longer needed
23
23
* The ` crate ` keyword refers to the current crate.
24
- * Relative paths variant: Paths work uniformly in both ` use ` statements and in
25
- other code, both in the top-level module and in submodules, and may use
24
+ * Relative paths variant: Paths work uniformly in both ` use ` declarations and
25
+ in other code, both in the top-level module and in submodules, and may use
26
26
either absolute paths or local names relative to the current module.
27
- * Absolute use paths variant: Paths in ` use ` statements are always absolute and
28
- begin with a crate name (or ` crate ` ); paths in other code may use absolute
29
- paths or local names relative to the current module.
27
+ * Absolute use paths variant: Paths in ` use ` declarations are always absolute
28
+ and begin with a crate name (or ` crate ` ); paths in other code may use
29
+ absolute paths or local names relative to the current module.
30
30
* The ` crate ` keyword also acts as a visibility modifier, equivalent to today's ` pub(crate) ` .
31
31
* A ` foo.rs ` and ` foo/ ` subdirectory may coexist; ` mod.rs ` is no longer needed
32
32
when placing submodules in a subdirectory.
@@ -73,10 +73,10 @@ Check [the macro section](2018/transitioning/modules/macros.html) for more.
73
73
74
74
### The ` crate ` keyword refers to the current crate.
75
75
76
- In ` use ` statements and in other code, you can refer to the root of the current
77
- crate with the ` crate:: ` prefix. For instance, ` crate::foo::bar ` will always
78
- refer to the name ` bar ` inside the module ` foo ` , from anywhere else in the same
79
- crate.
76
+ In ` use ` declarations and in other code, you can refer to the root of the
77
+ current crate with the ` crate:: ` prefix. For instance, ` crate::foo::bar ` will
78
+ always refer to the name ` bar ` inside the module ` foo ` , from anywhere else in
79
+ the same crate.
80
80
81
81
The prefix ` :: ` previously referred to either the crate root or an external
82
82
crate; it now unambiguously refers to an external crate. For instance,
@@ -85,14 +85,14 @@ crate; it now unambiguously refers to an external crate. For instance,
85
85
### Relative paths variant
86
86
87
87
The relative paths variant of Rust 2018 simplifies and unifies path handling
88
- compared to Rust 2015. In Rust 2015, paths work differently in use statements
89
- than they do elsewhere. In particular, paths in ` use ` statements would always
90
- start from the crate root, while paths in other code implicitly started from
91
- the current module. Those differences didn't have any effect in the top-level
92
- module, which meant that everything would seem straightforward until working on
93
- a project large enough to have submodules.
94
-
95
- In the relative paths variant of Rust 2018, paths in ` use ` statements and in
88
+ compared to Rust 2015. In Rust 2015, paths work differently in ` use `
89
+ declarations than they do elsewhere. In particular, paths in ` use `
90
+ declarations would always start from the crate root, while paths in other code
91
+ implicitly started from the current module. Those differences didn't have any
92
+ effect in the top-level module, which meant that everything would seem
93
+ straightforward until working on a project large enough to have submodules.
94
+
95
+ In the relative paths variant of Rust 2018, paths in ` use ` declarations and in
96
96
other code always work the same way, both in the top-level module and in any
97
97
submodule. You can either use a relative path from the current module, an
98
98
absolute path from the top of the current crate (starting with ` crate:: ` ), or
@@ -205,7 +205,7 @@ To explicitly disambiguate a path, use `::name` for an external crate name, or
205
205
206
206
### Absolute use paths variant
207
207
208
- In the absolute use paths variant of Rust 2018, paths in ` use ` statements
208
+ In the absolute use paths variant of Rust 2018, paths in ` use ` declarations
209
209
* must* begin with one of:
210
210
211
211
- A crate name
@@ -245,9 +245,9 @@ mod foo {
245
245
use crate::foo::Bar;
246
246
```
247
247
248
- In addition, all of these path forms are available outside of ` use ` statements
249
- as well, which eliminates many sources of confusion. Consider this code in Rust
250
- 2015:
248
+ In addition, all of these path forms are available outside of ` use `
249
+ declarations as well, which eliminates many sources of confusion. Consider this
250
+ code in Rust 2015:
251
251
252
252
``` rust,ignore
253
253
// Rust 2015
0 commit comments