1
Fork 0

change example of array_from_fn to match suggestion

This commit is contained in:
Fabian Hintringer 2022-11-25 10:05:07 +01:00
parent 480f850868
commit 69d562d684

View file

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