File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -302,16 +302,13 @@ where
302302 ///
303303 /// # Examples
304304 ///
305- /// This sums up every integer in a vector, rejecting the sum if a negative
306- /// element is encountered :
305+ /// This sums up the position of the character 'a' in a vector of strings,
306+ /// if a word did not have the character 'a' the operation returns `None` :
307307 ///
308308 /// ```
309- /// let v = vec![1, 2];
310- /// let res: Option<i32> = v.iter().map(|&x: &i32|
311- /// if x < 0 { None }
312- /// else { Some(x) }
313- /// ).sum();
314- /// assert_eq!(res, Some(3));
309+ /// let words = vec!["have", "a", "great", "day"];
310+ /// let total: Option<usize> = words.iter().map(|w| w.find('a')).sum();
311+ /// assert_eq!(total, Some(5));
315312 /// ```
316313 fn sum < I > ( iter : I ) -> Option < T >
317314 where
You can’t perform that action at this time.
0 commit comments