diff options
| author | zohnannor <zohnannor@gmail.com> | 2022-08-12 22:43:52 +0300 |
|---|---|---|
| committer | zohnannor <zohnannor@gmail.com> | 2022-08-12 22:43:52 +0300 |
| commit | 289ad1ac3882135fd3bc1387536978248dead9da (patch) | |
| tree | 0a9498d7e01b6b7d3aa5777737a592d47a19b488 /library/core/src/array | |
| parent | f22819bcce4abaff7d1246a56eec493418f9f4ee (diff) | |
| download | rust-289ad1ac3882135fd3bc1387536978248dead9da.tar.gz rust-289ad1ac3882135fd3bc1387536978248dead9da.zip | |
Clarify `array:from_fn` documentation
Diffstat (limited to 'library/core/src/array')
| -rw-r--r-- | library/core/src/array/mod.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index c9823a136bc..4d1ba6b1650 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]); /// ``` |
