Skip to content

Commit 2225ee1

Browse files
committed
Auto merge of #79925 - camelid:flatten-docs, r=scottmcm
Improve wording of `flatten()` docs
2 parents a9f7d19 + 97cd55e commit 2225ee1

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Diff for: library/core/src/iter/traits/iterator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ pub trait Iterator {
13321332
/// assert_eq!(merged, "alphabetagamma");
13331333
/// ```
13341334
///
1335-
/// Flattening once only removes one level of nesting:
1335+
/// Flattening only removes one level of nesting at a time:
13361336
///
13371337
/// ```
13381338
/// let d3 = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
@@ -1346,7 +1346,7 @@ pub trait Iterator {
13461346
///
13471347
/// Here we see that `flatten()` does not perform a "deep" flatten.
13481348
/// Instead, only one level of nesting is removed. That is, if you
1349-
/// `flatten()` a three-dimensional array the result will be
1349+
/// `flatten()` a three-dimensional array, the result will be
13501350
/// two-dimensional and not one-dimensional. To get a one-dimensional
13511351
/// structure, you have to `flatten()` again.
13521352
///

Diff for: library/core/src/option.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,9 @@ impl<T> Option<Option<T>> {
16951695
/// Converts from `Option<Option<T>>` to `Option<T>`
16961696
///
16971697
/// # Examples
1698+
///
16981699
/// Basic usage:
1700+
///
16991701
/// ```
17001702
/// let x: Option<Option<u32>> = Some(Some(6));
17011703
/// assert_eq!(Some(6), x.flatten());
@@ -1706,7 +1708,9 @@ impl<T> Option<Option<T>> {
17061708
/// let x: Option<Option<u32>> = None;
17071709
/// assert_eq!(None, x.flatten());
17081710
/// ```
1709-
/// Flattening once only removes one level of nesting:
1711+
///
1712+
/// Flattening only removes one level of nesting at a time:
1713+
///
17101714
/// ```
17111715
/// let x: Option<Option<Option<u32>>> = Some(Some(Some(6)));
17121716
/// assert_eq!(Some(Some(6)), x.flatten());

Diff for: library/core/src/result.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,9 @@ impl<T, E> Result<Result<T, E>, E> {
11841184
/// Converts from `Result<Result<T, E>, E>` to `Result<T, E>`
11851185
///
11861186
/// # Examples
1187+
///
11871188
/// Basic usage:
1189+
///
11881190
/// ```
11891191
/// #![feature(result_flattening)]
11901192
/// let x: Result<Result<&'static str, u32>, u32> = Ok(Ok("hello"));
@@ -1197,7 +1199,7 @@ impl<T, E> Result<Result<T, E>, E> {
11971199
/// assert_eq!(Err(6), x.flatten());
11981200
/// ```
11991201
///
1200-
/// Flattening once only removes one level of nesting:
1202+
/// Flattening only removes one level of nesting at a time:
12011203
///
12021204
/// ```
12031205
/// #![feature(result_flattening)]

0 commit comments

Comments
 (0)