Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up docs for 'as' keyword #78093

Merged
merged 1 commit into from
Nov 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions library/std/src/keyword_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@
/// ```
///
/// In general, any cast that can be performed via ascribing the type can also be done using `as`,
/// so instead of writing `let x: u32 = 123`, you can write `let x = 123 as u32` (Note: `let x: u32
/// = 123` would be best in that situation). The same is not true in the other direction, however,
/// so instead of writing `let x: u32 = 123`, you can write `let x = 123 as u32` (note: `let x: u32
/// = 123` would be best in that situation). The same is not true in the other direction, however;
/// explicitly using `as` allows a few more coercions that aren't allowed implicitly, such as
/// changing the type of a raw pointer or turning closures into raw pointers.
///
/// Other places `as` is used include as extra syntax for [`crate`] and `use`, to change the name
/// something is imported as.
camelid marked this conversation as resolved.
Show resolved Hide resolved
/// `as` is also used to rename imports in [`use`] and [`extern crate`] statements:
///
/// For more information on what `as` is capable of, see the [Reference]
/// ```
/// # #[allow(unused_imports)]
/// use std::{mem as memory, net as network};
/// // Now you can use the names `memory` and `network` to refer to `std::mem` and `std::net`.
/// ```
///
/// For more information on what `as` is capable of, see the [Reference].
///
/// [Reference]: ../reference/expressions/operator-expr.html#type-cast-expressions
/// [`crate`]: keyword.crate.html
/// [`use`]: keyword.use.html
/// [`extern crate`]: keyword.crate.html
mod as_keyword {}

#[doc(keyword = "break")]
Expand Down Expand Up @@ -397,6 +403,7 @@ mod enum_keyword {}
/// [Rust book]:
/// ../book/ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code
/// [Reference]: ../reference/items/external-blocks.html
/// [`crate`]: keyword.crate.html
camelid marked this conversation as resolved.
Show resolved Hide resolved
mod extern_keyword {}

#[doc(keyword = "false")]
Expand Down