Skip to content

Commit

Permalink
Auto merge of #79925 - camelid:flatten-docs, r=scottmcm
Browse files Browse the repository at this point in the history
Improve wording of `flatten()` docs
  • Loading branch information
bors committed Dec 11, 2020
2 parents a9f7d19 + 97cd55e commit 2225ee1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ pub trait Iterator {
/// assert_eq!(merged, "alphabetagamma");
/// ```
///
/// Flattening once only removes one level of nesting:
/// Flattening only removes one level of nesting at a time:
///
/// ```
/// let d3 = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
Expand All @@ -1346,7 +1346,7 @@ pub trait Iterator {
///
/// Here we see that `flatten()` does not perform a "deep" flatten.
/// Instead, only one level of nesting is removed. That is, if you
/// `flatten()` a three-dimensional array the result will be
/// `flatten()` a three-dimensional array, the result will be
/// two-dimensional and not one-dimensional. To get a one-dimensional
/// structure, you have to `flatten()` again.
///
Expand Down
6 changes: 5 additions & 1 deletion library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,9 @@ impl<T> Option<Option<T>> {
/// Converts from `Option<Option<T>>` to `Option<T>`
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let x: Option<Option<u32>> = Some(Some(6));
/// assert_eq!(Some(6), x.flatten());
Expand All @@ -1706,7 +1708,9 @@ impl<T> Option<Option<T>> {
/// let x: Option<Option<u32>> = None;
/// assert_eq!(None, x.flatten());
/// ```
/// Flattening once only removes one level of nesting:
///
/// Flattening only removes one level of nesting at a time:
///
/// ```
/// let x: Option<Option<Option<u32>>> = Some(Some(Some(6)));
/// assert_eq!(Some(Some(6)), x.flatten());
Expand Down
4 changes: 3 additions & 1 deletion library/core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,9 @@ impl<T, E> Result<Result<T, E>, E> {
/// Converts from `Result<Result<T, E>, E>` to `Result<T, E>`
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(result_flattening)]
/// let x: Result<Result<&'static str, u32>, u32> = Ok(Ok("hello"));
Expand All @@ -1197,7 +1199,7 @@ impl<T, E> Result<Result<T, E>, E> {
/// assert_eq!(Err(6), x.flatten());
/// ```
///
/// Flattening once only removes one level of nesting:
/// Flattening only removes one level of nesting at a time:
///
/// ```
/// #![feature(result_flattening)]
Expand Down

0 comments on commit 2225ee1

Please sign in to comment.