@@ -1495,18 +1495,6 @@ pub trait Iterator {
1495
1495
/// assert_eq!(merged, "alphabetagamma");
1496
1496
/// ```
1497
1497
///
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
- ///
1510
1498
/// You can also rewrite this in terms of [`flat_map()`], which is preferable
1511
1499
/// in this case since it conveys intent more clearly:
1512
1500
///
@@ -1520,6 +1508,18 @@ pub trait Iterator {
1520
1508
/// assert_eq!(merged, "alphabetagamma");
1521
1509
/// ```
1522
1510
///
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
+ ///
1523
1523
/// Flattening only removes one level of nesting at a time:
1524
1524
///
1525
1525
/// ```
0 commit comments