@@ -1213,9 +1213,61 @@ mod unsafe_keyword {}
1213
1213
//
1214
1214
/// Import or rename items from other crates or modules.
1215
1215
///
1216
- /// The documentation for this keyword is [not yet complete]. Pull requests welcome!
1216
+ /// Usually a `use` keyword is used to shorten the path required to refer to a module item.
1217
+ /// The keyword may appear in modules, blocks and even functions, usually at the top.
1218
+ ///
1219
+ /// The most basic usage of the keyword is `use path::to::item;`,
1220
+ /// though a number of convenient shortcuts are supported:
1221
+ ///
1222
+ /// * Simultaneously binding a list of paths with a common prefix,
1223
+ /// using the glob-like brace syntax `use a::b::{c, d, e::f, g::h::i};`
1224
+ /// * Simultaneously binding a list of paths with a common prefix and their common parent module,
1225
+ /// using the [`self`] keyword, such as `use a::b::{self, c, d::e};`
1226
+ /// * Rebinding the target name as a new local name, using the syntax `use p::q::r as x;`.
1227
+ /// This can also be used with the last two features: `use a::b::{self as ab, c as abc}`.
1228
+ /// * Binding all paths matching a given prefix,
1229
+ /// using the asterisk wildcard syntax `use a::b::*;`.
1230
+ /// * Nesting groups of the previous features multiple times,
1231
+ /// such as `use a::b::{self as ab, c, d::{*, e::f}};`
1232
+ /// * Reexporting with visibility modifiers such as `pub use a::b;`
1233
+ /// * Importing with `_` to only import the methods of a trait without binding it to a name
1234
+ /// (to avoid conflict for example): `use ::std::io::Read as _;`.
1235
+ ///
1236
+ /// Using path qualifiers like [`crate`], [`super`] or [`self`] is supported: `use crate::a::b;`.
1237
+ ///
1238
+ /// Note that when the wildcard `*` is used on a type, it does not import its methods (though
1239
+ /// for `enum`s it imports the variants, as shown in the example below).
1240
+ ///
1241
+ /// ```compile_fail,edition2018
1242
+ /// enum ExampleEnum {
1243
+ /// VariantA,
1244
+ /// VariantB,
1245
+ /// }
1217
1246
///
1218
- /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
1247
+ /// impl ExampleEnum {
1248
+ /// fn new() -> Self {
1249
+ /// Self::VariantA
1250
+ /// }
1251
+ /// }
1252
+ ///
1253
+ /// use ExampleEnum::*;
1254
+ ///
1255
+ /// // Compiles.
1256
+ /// let _ = VariantA;
1257
+ ///
1258
+ /// // Does not compile !
1259
+ /// let n = new();
1260
+ /// ```
1261
+ ///
1262
+ /// For more information on `use` and paths in general, see the [Reference].
1263
+ ///
1264
+ /// The differences about paths and the `use` keyword between the 2015 and 2018 editions
1265
+ /// can also be found in the [Reference].
1266
+ ///
1267
+ /// [`crate`]: keyword.crate.html
1268
+ /// [`self`]: keyword.self.html
1269
+ /// [`super`]: keyword.super.html
1270
+ /// [Reference]: ../reference/items/use-declarations.html
1219
1271
mod use_keyword { }
1220
1272
1221
1273
#[ doc( keyword = "where" ) ]
0 commit comments