Skip to content

Commit

Permalink
Clarify array:from_fn documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
zohnannor committed Aug 12, 2022
1 parent f22819b commit 289ad1a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
/// ```
Expand Down

0 comments on commit 289ad1a

Please sign in to comment.