From 1994cee61a4aea9dc46bb3d0323c8290621eda33 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 26 Sep 2020 00:04:34 +0800 Subject: [PATCH 1/2] Add alias for iterator fold fold is known in python and javascript as reduce, not sure about inject but it was written in doc there. --- library/core/src/iter/traits/iterator.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index f70e92f0ffa..ec257a11465 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -1977,6 +1977,8 @@ pub trait Iterator { /// assert_eq!(result, result2); /// ``` #[inline] + #[doc(alias = "reduce")] + #[doc(alias = "inject")] #[stable(feature = "rust1", since = "1.0.0")] fn fold(mut self, init: B, mut f: F) -> B where From ea0065ad4f96153539476e2f3df83bae96018ede Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sat, 26 Sep 2020 00:05:37 +0800 Subject: [PATCH 2/2] Reposition iterator doc alias reduce before inline --- library/core/src/iter/traits/iterator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index ec257a11465..a0f7f294e6f 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -1976,9 +1976,9 @@ pub trait Iterator { /// // they're the same /// assert_eq!(result, result2); /// ``` - #[inline] #[doc(alias = "reduce")] #[doc(alias = "inject")] + #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn fold(mut self, init: B, mut f: F) -> B where