File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 6
6
# Summary
7
7
[ summary ] : #summary
8
8
9
- The ` use … ( … as …) ` syntax can now accept a wildcard ` _ ` as alias to a trait to only import the
9
+ The ` use …::{ … as …} ` syntax can now accept ` _ ` as alias to a trait to only import the
10
10
implementations of such a trait.
11
11
12
12
# Motivation
@@ -88,7 +88,30 @@ The `_` means that you “don’t care about the name rustc will use for that qu
88
88
# Reference-level explanation
89
89
[ reference-level-explanation ] : #reference-level-explanation
90
90
91
- To be defined.
91
+ ` use Trait as _ ` needs to desugar into ` use Trait as SomeGenSym ` . With this scheme, global imports
92
+ and exports can work properly with such items, i.e. import / re-export them.
93
+
94
+ ``` rust
95
+ mod m {
96
+ pub use Trait as _;
97
+
98
+ // `Trait` is in scope
99
+ }
100
+
101
+ use m :: * ;
102
+
103
+ // `Trait` is in scope too
104
+ ```
105
+
106
+ In the case where the symbol is not a * trait* , it works the exact same way. However, a warning must
107
+ be emitted by the compiler to state the unused import (as types don’t have ` impl ` !).
108
+
109
+ In the same way, it’s possible to use the same mechanism with ` extern crate ` for linking-only
110
+ crates:
111
+
112
+ ``` rust
113
+ extern crate my_crate as _;
114
+ ```
92
115
93
116
# Drawbacks
94
117
[ drawbacks ] : #drawbacks
You can’t perform that action at this time.
0 commit comments