Skip to content

Commit d44e165

Browse files
authored
Rollup merge of rust-lang#78093 - camelid:as-cleanup, r=jyn514
Clean up docs for 'as' keyword
2 parents dea29bd + d8afe98 commit d44e165

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

library/std/src/keyword_docs.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,24 @@
1515
/// ```
1616
///
1717
/// In general, any cast that can be performed via ascribing the type can also be done using `as`,
18-
/// so instead of writing `let x: u32 = 123`, you can write `let x = 123 as u32` (Note: `let x: u32
19-
/// = 123` would be best in that situation). The same is not true in the other direction, however,
18+
/// so instead of writing `let x: u32 = 123`, you can write `let x = 123 as u32` (note: `let x: u32
19+
/// = 123` would be best in that situation). The same is not true in the other direction, however;
2020
/// explicitly using `as` allows a few more coercions that aren't allowed implicitly, such as
2121
/// changing the type of a raw pointer or turning closures into raw pointers.
2222
///
23-
/// Other places `as` is used include as extra syntax for [`crate`] and `use`, to change the name
24-
/// something is imported as.
23+
/// `as` is also used to rename imports in [`use`] and [`extern crate`] statements:
2524
///
26-
/// For more information on what `as` is capable of, see the [Reference]
25+
/// ```
26+
/// # #[allow(unused_imports)]
27+
/// use std::{mem as memory, net as network};
28+
/// // Now you can use the names `memory` and `network` to refer to `std::mem` and `std::net`.
29+
/// ```
30+
///
31+
/// For more information on what `as` is capable of, see the [Reference].
2732
///
2833
/// [Reference]: ../reference/expressions/operator-expr.html#type-cast-expressions
29-
/// [`crate`]: keyword.crate.html
34+
/// [`use`]: keyword.use.html
35+
/// [`extern crate`]: keyword.crate.html
3036
mod as_keyword {}
3137

3238
#[doc(keyword = "break")]
@@ -397,6 +403,7 @@ mod enum_keyword {}
397403
/// [Rust book]:
398404
/// ../book/ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code
399405
/// [Reference]: ../reference/items/external-blocks.html
406+
/// [`crate`]: keyword.crate.html
400407
mod extern_keyword {}
401408

402409
#[doc(keyword = "false")]

0 commit comments

Comments
 (0)