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