Rollup merge of #115053 - waywardmonkeys:augment-type-keyword-docs, r=cuviper

docs: Add example, reference link for `type` keyword.

Fixes #114281.
This commit is contained in:
Dylan DPC 2023-08-23 05:35:16 +00:00 committed by GitHub
commit 21411c4db5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -1820,7 +1820,7 @@ mod true_keyword {}
#[doc(keyword = "type")]
//
/// Define an alias for an existing type.
/// Define an [alias] for an existing type.
///
/// The syntax is `type Name = ExistingType;`.
///
@ -1838,6 +1838,13 @@ mod true_keyword {}
/// assert_eq!(m, k);
/// ```
///
/// A type can be generic:
///
/// ```rust
/// # use std::sync::{Arc, Mutex};
/// type ArcMutex<T> = Arc<Mutex<T>>;
/// ```
///
/// In traits, `type` is used to declare an [associated type]:
///
/// ```rust
@ -1860,6 +1867,7 @@ mod true_keyword {}
///
/// [`trait`]: keyword.trait.html
/// [associated type]: ../reference/items/associated-items.html#associated-types
/// [alias]: ../reference/items/type-aliases.html
mod type_keyword {}
#[doc(keyword = "unsafe")]