Skip to content

Commit 25a8433

Browse files
committed
Add tracking issue rust-lang#75243
Add note & example about iter order Add doc changes Update doc comments
1 parent 2cba121 commit 25a8433

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

library/core/src/array/mod.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -368,16 +368,23 @@ 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
368368
#[cfg(not(bootstrap))]
369369
#[lang = "array"]
370370
impl<T, const N: usize> [T; N] {
371-
/// Returns an array of the same size as self, with `f` applied to each element.
371+
/// Returns an array of the same size as `self`, with function `f` applied to each element.
372+
/// The closure will be called on elements 0 up to but excluding N.
372373
///
373374
/// # Examples
375+
///
374376
/// ```
375377
/// # #![feature(array_map)]
376378
/// let x = [1, 2, 3];
377379
/// let y = x.map(|v| v + 1);
378380
/// assert_eq!(y, [2, 3, 4]);
381+
///
382+
/// let x = [1, 2, 3];
383+
/// let mut temp = 0;
384+
/// let y = x.map(|v| { temp += 1; v * temp });
385+
/// assert_eq!(y, [1, 4, 9]);
379386
/// ```
380-
#[unstable(feature = "array_map", issue = "77777")]
387+
#[unstable(feature = "array_map", issue = "75243")]
381388
pub fn map<F, U>(self, mut f: F) -> [U; N]
382389
where
383390
F: FnMut(T) -> U,

0 commit comments

Comments
 (0)