Add docs for crate
keyword
I think it might be used in some other things, but I'm not fluent enough at sifting through the rust compiler's source code to find every use of a specific keyword. This leaves the question of how to document the `extern` keyword, what with how much overlap it has with `crate`, but that's used with ABI stuff so that should be fine.
This commit is contained in:
parent
6cbcfa2761
commit
f8d6261f9b
1 changed files with 34 additions and 0 deletions
|
@ -90,6 +90,40 @@ mod as_keyword { }
|
|||
/// [Reference]: https://doc.rust-lang.org/reference/items/constant-items.html
|
||||
mod const_keyword { }
|
||||
|
||||
#[doc(keyword = "crate")]
|
||||
//
|
||||
/// The `crate` keyword.
|
||||
///
|
||||
/// The primary use of the `crate` keyword is as a part of `extern crate` declarations, which are
|
||||
/// used to specify a dependency on a crate external to the one it's declared in. Crates are the
|
||||
/// fundamental compilation unit of Rust code, and can be seen as libraries or projects. More can
|
||||
/// be read about crates in the [Reference].
|
||||
///
|
||||
/// ```rust ignore
|
||||
/// extern crate rand;
|
||||
/// extern crate my_crate as thing;
|
||||
/// extern crate std; // implicitly added to the root of every Rust project
|
||||
/// ```
|
||||
///
|
||||
/// The `as` keyword can be used to change what the crate is referred to as in your project. If a
|
||||
/// crate name includes a dash, it is implicitly imported with the dashes replaced by underscores.
|
||||
///
|
||||
/// `crate` is also used as in conjunction with [`pub`] to signify that the item it's attached to
|
||||
/// is public only to other members of the same crate it's in.
|
||||
///
|
||||
/// ```rust
|
||||
/// # #[allow(unused_imports)]
|
||||
/// pub(crate) use std::io::Error as IoError;
|
||||
/// pub(crate) enum CoolMarkerType { }
|
||||
/// pub struct PublicThing {
|
||||
/// pub(crate) semi_secret_thing: bool,
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// [Reference]: https://doc.rust-lang.org/reference/items/extern-crates.html
|
||||
/// [`pub`]: keyword.pub.html
|
||||
mod crate_keyword { }
|
||||
|
||||
#[doc(keyword = "fn")]
|
||||
//
|
||||
/// The `fn` keyword.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue