Clarify array:from_fn documentation

This commit is contained in:
zohnannor
2022-08-12 22:43:52 +03:00
parent f22819bcce
commit 289ad1ac38

View File

@@ -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]);
/// ```