From 289ad1ac3882135fd3bc1387536978248dead9da Mon Sep 17 00:00:00 2001 From: zohnannor Date: Fri, 12 Aug 2022 22:43:52 +0300 Subject: [PATCH] Clarify `array:from_fn` documentation --- library/core/src/array/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index c9823a136bc42..4d1ba6b1650c1 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -31,6 +31,10 @@ pub use iter::IntoIter; /// # Example /// /// ```rust +/// // type inference is helping us here, the way `from_fn` knows how many +/// // elements to produce is the length of array down there: only arrays of +/// // equal lengths can be compared, so the const generic parameter `N` is +/// // inferred to be 5, thus creating array of 5 elements. /// let array = core::array::from_fn(|i| i); /// assert_eq!(array, [0, 1, 2, 3, 4]); /// ```