diff options
| author | Michael Howell <michael@notriddle.com> | 2022-06-08 19:26:51 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2022-06-08 19:26:51 -0700 |
| commit | 6950f144cf83d10bc4a304b48488f9f5368cfaae (patch) | |
| tree | cdb01e93a5aa5912f6ef07deef7ba8c622027f67 /library/std/src | |
| parent | 7a935670055d87e17c381542f4eaab481e8bf17b (diff) | |
| download | rust-6950f144cf83d10bc4a304b48488f9f5368cfaae.tar.gz rust-6950f144cf83d10bc4a304b48488f9f5368cfaae.zip | |
rustdoc: show tuple impls as `impl Trait for (T, ...)`
This commit adds a new unstable attribute, `#[doc(tuple_varadic)]`, that shows a 1-tuple as `(T, ...)` instead of just `(T,)`, and links to a section in the tuple primitive docs that talks about these.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/primitive_docs.rs | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index db2f7ec0e0e..26f9528dd22 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -916,24 +916,11 @@ mod prim_str {} /// /// # Trait implementations /// -/// If every type inside a tuple implements one of the following traits, then a -/// tuple itself also implements it. -/// -/// * [`Clone`] -/// * [`Copy`] -/// * [`PartialEq`] -/// * [`Eq`] -/// * [`PartialOrd`] -/// * [`Ord`] -/// * [`Debug`] -/// * [`Default`] -/// * [`Hash`] -/// -/// [`Debug`]: fmt::Debug -/// [`Hash`]: hash::Hash -/// -/// Due to a temporary restriction in Rust's type system, these traits are only -/// implemented on tuples of arity 12 or less. In the future, this may change. +/// In this documentation the shorthand `(T, ...)` is used to represent all +/// tuples up to length twelve. When that is used, any trait bounds expressed +/// on `T` applies to each field of the tuple independently. Note that this is +/// a convenience notation to avoid repetitive documentation, not valid +/// Rust syntax. /// /// # Examples /// @@ -978,6 +965,7 @@ impl<T, U> (T, U) {} // Fake impl that's only really used for docs. #[cfg(doc)] #[stable(feature = "rust1", since = "1.0.0")] +#[doc(tuple_varadic)] /// This trait is implemented on arbitrary-length tuples. impl<T: Clone> Clone for (T,) { fn clone(&self) -> Self { @@ -988,6 +976,7 @@ impl<T: Clone> Clone for (T,) { // Fake impl that's only really used for docs. #[cfg(doc)] #[stable(feature = "rust1", since = "1.0.0")] +#[doc(tuple_varadic)] /// This trait is implemented on arbitrary-length tuples. impl<T: Copy> Copy for (T,) { // empty |
