File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff 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
369
369
#[ lang = "array" ]
370
370
impl < T , const N : usize > [ T ; N ] {
371
371
/// 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.
372
373
///
373
374
/// # Examples
374
375
/// ```
375
376
/// # #![feature(array_map)]
376
377
/// let x = [1, 2, 3];
377
378
/// let y = x.map(|v| v + 1);
378
379
/// 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]);
379
385
/// ```
380
- #[ unstable( feature = "array_map" , issue = "75027 " ) ]
386
+ #[ unstable( feature = "array_map" , issue = "75243 " ) ]
381
387
pub fn map < F , U > ( self , mut f : F ) -> [ U ; N ]
382
388
where
383
389
F : FnMut ( T ) -> U ,
You can’t perform that action at this time.
0 commit comments