Skip to content

Commit

Permalink
change example of array_from_fn to match suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
HintringerFabian committed Nov 25, 2022
1 parent 480f850 commit 69d562d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ pub use iter::IntoIter;
/// // equal lengths can be compared, so the const generic parameter `N` is
/// // inferred to be 5, thus creating array of 5 elements.
///
/// let array: [_; 5] = core::array::from_fn(|i| i);
/// let array = core::array::from_fn(|i| i);
/// // indexes are: 0 1 2 3 4
/// assert_eq!(array, [0, 1, 2, 3, 4]);
///
/// let array2: [_; 8] = core::array::from_fn(|i| i * 2);
/// let array2: [usize; 8] = core::array::from_fn(|i| i * 2);
/// // indexes are: 0 1 2 3 4 5 6 7
/// assert_eq!(array2, [0, 2, 4, 6, 8, 10, 12, 14]);
///
/// let bool_arr: [bool; 5] = core::array::from_fn(|i| i % 2 == 0);
/// let bool_arr = core::array::from_fn::<_, 5, _>(|i| i % 2 == 0);
/// // indexes are: 0 1 2 3 4
/// assert_eq!(bool_arr, [true, false, true, false, true]);
/// ```
Expand Down

0 comments on commit 69d562d

Please sign in to comment.