Skip to content

Commit 751bdb8

Browse files
committed
Add note & example about iter order
1 parent b7c33ac commit 751bdb8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

library/core/src/array/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,15 +369,21 @@ array_impl_default! {32, T T T T T T T T T T T T T T T T T T T T T T T T T T T T
369369
#[lang = "array"]
370370
impl<T, const N: usize> [T; N] {
371371
/// Returns an array of the same size as self, with `f` applied to each element.
372+
/// The closure will be called on elements 0 up to N.
372373
///
373374
/// # Examples
374375
/// ```
375376
/// # #![feature(array_map)]
376377
/// let x = [1, 2, 3];
377378
/// let y = x.map(|v| v + 1);
378379
/// assert_eq!(y, [2, 3, 4]);
380+
///
381+
/// let x = [1, 2, 3];
382+
/// let mut temp = 0;
383+
/// let y = x.map(|v| { temp += 1; v * temp });
384+
/// assert_eq!(y, [1, 4, 9]);
379385
/// ```
380-
#[unstable(feature = "array_map", issue = "75027")]
386+
#[unstable(feature = "array_map", issue = "75243")]
381387
pub fn map<F, U>(self, mut f: F) -> [U; N]
382388
where
383389
F: FnMut(T) -> U,

0 commit comments

Comments
 (0)