Skip to content

Commit

Permalink
Document the type keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
poliorcetics committed Jun 27, 2020
1 parent 394e1b4 commit 3fc5593
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/libstd/keyword_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1463,9 +1463,33 @@ mod true_keyword {}
//
/// Define an alias for an existing type.
///
/// The documentation for this keyword is [not yet complete]. Pull requests welcome!
/// The syntax is `type Name = ExistingType;`.
///
/// [not yet complete]: https://github.com/rust-lang/rust/issues/34601
/// # Examples
///
/// `type` does **not** create a new type:
///
/// ```rust
/// type Meters = u32;
/// type Kilograms = u32;
///
/// let m: Meters = 3;
/// let k: Kilograms = 3;
///
/// assert_eq!(m, k);
/// ```
///
/// In traits, using `type` allows the usage of an associated type without
/// knowing about it when declaring the [`trait`]:
///
/// ```rust
/// trait Iterator {
/// type Item;
/// fn next(&mut self) -> Option<Self::Item>;
/// }
/// ```
///
/// [`trait`]: keyword.trait.html
mod type_keyword {}

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

0 comments on commit 3fc5593

Please sign in to comment.