File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 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
368368#[ cfg( not( bootstrap) ) ]
369369#[ lang = "array" ]
370370impl < 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.
372373 ///
373374 /// # Examples
375+ ///
374376 /// ```
375377 /// # #![feature(array_map)]
376378 /// let x = [1, 2, 3];
377379 /// let y = x.map(|v| v + 1);
378380 /// 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]);
379386 /// ```
380- #[ unstable( feature = "array_map" , issue = "77777 " ) ]
387+ #[ unstable( feature = "array_map" , issue = "75243 " ) ]
381388 pub fn map < F , U > ( self , mut f : F ) -> [ U ; N ]
382389 where
383390 F : FnMut ( T ) -> U ,
You can’t perform that action at this time.
0 commit comments