Skip to content

Commit

Permalink
Rm hiding feature gate & add 1 more example
Browse files Browse the repository at this point in the history
Update order docs for `map`
  • Loading branch information
JulianKnodt committed Aug 13, 2020
1 parent 54b821e commit 412417d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
#[cfg(not(bootstrap))]
#[lang = "array"]
impl<T, const N: usize> [T; N] {
/// Returns an array of the same size as `self`, with function `f` applied to each element.
/// The closure will be called on elements 0 up to but excluding N.
/// Returns an array of the same size as `self`, with function `f` applied to each element
/// in order.
///
/// # Examples
///
/// ```
/// # #![feature(array_map)]
/// #![feature(array_map)]
/// let x = [1, 2, 3];
/// let y = x.map(|v| v + 1);
/// assert_eq!(y, [2, 3, 4]);
Expand All @@ -383,6 +383,10 @@ impl<T, const N: usize> [T; N] {
/// let mut temp = 0;
/// let y = x.map(|v| { temp += 1; v * temp });
/// assert_eq!(y, [1, 4, 9]);
///
/// let x = ["Ferris", "Bueller's", "Day", "Off"];
/// let y = x.map(|v| v.len());
/// assert_eq!(y, [6, 9, 3, 3]);
/// ```
#[unstable(feature = "array_map", issue = "75243")]
pub fn map<F, U>(self, mut f: F) -> [U; N]
Expand Down

0 comments on commit 412417d

Please sign in to comment.