Rollup merge of #86389 - kpreid:sum, r=scottmcm

Make `sum()` and `product()` documentation hyperlinks refer to `Iterator` methods.

The previous linking seemed confusing: within "the sum() method on iterators", "sum()" was linked to `Sum::sum`, not `Iterator::sum`, even though the sentence is talking about the latter. I have rewritten the sentence to be, I believe, clearer, as well as changing the link destinations; applying the same change to the `Product` documentation as well as `Sum`.

I reviewed other traits in the same module and did not see similar issues, and previewed the results using `./x.py doc library/std`.
This commit is contained in:
Yuki Okushi 2021-06-17 21:56:46 +09:00 committed by GitHub
commit 65d412b637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,12 +3,11 @@ use crate::num::Wrapping;
/// Trait to represent types that can be created by summing up an iterator. /// Trait to represent types that can be created by summing up an iterator.
/// ///
/// This trait is used to implement the [`sum()`] method on iterators. Types which /// This trait is used to implement [`Iterator::sum()`]. Types which implement
/// implement the trait can be generated by the [`sum()`] method. Like /// this trait can be generated by using the [`sum()`] method on an iterator.
/// [`FromIterator`] this trait should rarely be called directly and instead /// Like [`FromIterator`], this trait should rarely be called directly.
/// interacted with through [`Iterator::sum()`].
/// ///
/// [`sum()`]: Sum::sum /// [`sum()`]: Iterator::sum
/// [`FromIterator`]: iter::FromIterator /// [`FromIterator`]: iter::FromIterator
#[stable(feature = "iter_arith_traits", since = "1.12.0")] #[stable(feature = "iter_arith_traits", since = "1.12.0")]
pub trait Sum<A = Self>: Sized { pub trait Sum<A = Self>: Sized {
@ -21,12 +20,11 @@ pub trait Sum<A = Self>: Sized {
/// Trait to represent types that can be created by multiplying elements of an /// Trait to represent types that can be created by multiplying elements of an
/// iterator. /// iterator.
/// ///
/// This trait is used to implement the [`product()`] method on iterators. Types /// This trait is used to implement [`Iterator::product()`]. Types which implement
/// which implement the trait can be generated by the [`product()`] method. Like /// this trait can be generated by using the [`product()`] method on an iterator.
/// [`FromIterator`] this trait should rarely be called directly and instead /// Like [`FromIterator`], this trait should rarely be called directly.
/// interacted with through [`Iterator::product()`].
/// ///
/// [`product()`]: Product::product /// [`product()`]: Iterator::product
/// [`FromIterator`]: iter::FromIterator /// [`FromIterator`]: iter::FromIterator
#[stable(feature = "iter_arith_traits", since = "1.12.0")] #[stable(feature = "iter_arith_traits", since = "1.12.0")]
pub trait Product<A = Self>: Sized { pub trait Product<A = Self>: Sized {