Skip to content

Improve wording of flatten() docs #79925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Contributor

@pickfire pickfire Dec 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Flattening only removes one level of nesting at a time:
/// Flattening only removes one level of nesting once:

"at a time" is not clear that it happened once, feels like a play a words, people may not notice it if not careful. Oh, after reading it I find it being extra, we can even remove "at a time" or "once".

Flattening only removes one level of nesting

I think would be clear enough.

///
/// ```
/// 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