@@ -1213,9 +1213,63 @@ mod unsafe_keyword {}
12131213//
12141214/// Import or rename items from other crates or modules.
12151215///
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 the item 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
1242+ /// # fn main() {
1243+ /// enum ExampleEnum {
1244+ /// VariantA,
1245+ /// VariantB,
1246+ /// }
12171247///
1218- /// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
1248+ /// impl ExampleEnum {
1249+ /// fn new() -> Self {
1250+ /// Self::VariantA
1251+ /// }
1252+ /// }
1253+ ///
1254+ /// use ExampleEnum::*;
1255+ ///
1256+ /// // Compiles.
1257+ /// let _ = VariantA;
1258+ ///
1259+ /// // Does not compile !
1260+ /// let n = new();
1261+ /// # }
1262+ /// ```
1263+ ///
1264+ /// For more information on `use` and paths in general, see the [Reference].
1265+ ///
1266+ /// The differences about paths and the `use` keyword between the 2015 and 2018 editions
1267+ /// can also be found in the [Reference].
1268+ ///
1269+ /// [`crate`]: keyword.crate.html
1270+ /// [`self`]: keyword.self.html
1271+ /// [`super`]: keyword.super.html
1272+ /// [Reference]: ../reference/items/use-declarations.html
12191273mod use_keyword { }
12201274
12211275#[ doc( keyword = "where" ) ]
0 commit comments