@@ -1495,18 +1495,6 @@ pub trait Iterator {
14951495 /// assert_eq!(merged, "alphabetagamma");
14961496 /// ```
14971497 ///
1498- /// Flattening works on any `IntoIterator` type, including `Option` and `Result`:
1499- ///
1500- /// ```
1501- /// let options = vec![Some(123), Some(321), None, Some(231)];
1502- /// let flattened_options: Vec<_> = options.into_iter().flatten().collect();
1503- /// assert_eq!(flattened_options, vec![123, 321, 231]);
1504- ///
1505- /// let results = vec![Ok(123), Ok(321), Err(456), Ok(231)];
1506- /// let flattened_results: Vec<_> = results.into_iter().flatten().collect();
1507- /// assert_eq!(flattened_results, vec![123, 321, 231]);
1508- /// ```
1509- ///
15101498 /// You can also rewrite this in terms of [`flat_map()`], which is preferable
15111499 /// in this case since it conveys intent more clearly:
15121500 ///
@@ -1520,6 +1508,18 @@ pub trait Iterator {
15201508 /// assert_eq!(merged, "alphabetagamma");
15211509 /// ```
15221510 ///
1511+ /// Flattening works on any `IntoIterator` type, including `Option` and `Result`:
1512+ ///
1513+ /// ```
1514+ /// let options = vec![Some(123), Some(321), None, Some(231)];
1515+ /// let flattened_options: Vec<_> = options.into_iter().flatten().collect();
1516+ /// assert_eq!(flattened_options, vec![123, 321, 231]);
1517+ ///
1518+ /// let results = vec![Ok(123), Ok(321), Err(456), Ok(231)];
1519+ /// let flattened_results: Vec<_> = results.into_iter().flatten().collect();
1520+ /// assert_eq!(flattened_results, vec![123, 321, 231]);
1521+ /// ```
1522+ ///
15231523 /// Flattening only removes one level of nesting at a time:
15241524 ///
15251525 /// ```
0 commit comments