Add tracking issue #75243
Add note & example about iter order Add doc changes Update doc comments
This commit is contained in:
@@ -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
|
|||||||
#[cfg(not(bootstrap))]
|
#[cfg(not(bootstrap))]
|
||||||
#[lang = "array"]
|
#[lang = "array"]
|
||||||
impl<T, const N: usize> [T; N] {
|
impl<T, const N: usize> [T; N] {
|
||||||
/// Returns an array of the same size as self, with `f` applied to each element.
|
/// 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.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # #![feature(array_map)]
|
/// # #![feature(array_map)]
|
||||||
/// let x = [1, 2, 3];
|
/// let x = [1, 2, 3];
|
||||||
/// let y = x.map(|v| v + 1);
|
/// let y = x.map(|v| v + 1);
|
||||||
/// assert_eq!(y, [2, 3, 4]);
|
/// assert_eq!(y, [2, 3, 4]);
|
||||||
|
///
|
||||||
|
/// let x = [1, 2, 3];
|
||||||
|
/// let mut temp = 0;
|
||||||
|
/// let y = x.map(|v| { temp += 1; v * temp });
|
||||||
|
/// assert_eq!(y, [1, 4, 9]);
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "array_map", issue = "77777")]
|
#[unstable(feature = "array_map", issue = "75243")]
|
||||||
pub fn map<F, U>(self, mut f: F) -> [U; N]
|
pub fn map<F, U>(self, mut f: F) -> [U; N]
|
||||||
where
|
where
|
||||||
F: FnMut(T) -> U,
|
F: FnMut(T) -> U,
|
||||||
|
|||||||
Reference in New Issue
Block a user