Skip to content

Commit 412417d

Browse files
committed
Rm hiding feature gate & add 1 more example
Update order docs for `map`
1 parent 54b821e commit 412417d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: library/core/src/array/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,13 @@ 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 function `f` applied to each element.
372-
/// The closure will be called on elements 0 up to but excluding N.
371+
/// Returns an array of the same size as `self`, with function `f` applied to each element
372+
/// in order.
373373
///
374374
/// # Examples
375375
///
376376
/// ```
377-
/// # #![feature(array_map)]
377+
/// #![feature(array_map)]
378378
/// let x = [1, 2, 3];
379379
/// let y = x.map(|v| v + 1);
380380
/// assert_eq!(y, [2, 3, 4]);
@@ -383,6 +383,10 @@ impl<T, const N: usize> [T; N] {
383383
/// let mut temp = 0;
384384
/// let y = x.map(|v| { temp += 1; v * temp });
385385
/// assert_eq!(y, [1, 4, 9]);
386+
///
387+
/// let x = ["Ferris", "Bueller's", "Day", "Off"];
388+
/// let y = x.map(|v| v.len());
389+
/// assert_eq!(y, [6, 9, 3, 3]);
386390
/// ```
387391
#[unstable(feature = "array_map", issue = "75243")]
388392
pub fn map<F, U>(self, mut f: F) -> [U; N]

0 commit comments

Comments
 (0)