Skip to content

Commit

Permalink
Rollup merge of #64747 - ethanboxx:master, r=Centril
Browse files Browse the repository at this point in the history
Stabilize `Option::flatten`

- PR: #60256
- Tracking issue: #60258

@elahn

> I was trying to `flat_map()` and found `map().flatten()` does the trick. This has been on nightly for 4 months, can we stabilise it?

@ethanboxx

> @Centril Helped me get this merged. What is the stabilization process?

@Centril

> @ethanboxx I'd just file a PR to stabilize it and we'll ask T-libs to FCP.

So here I am.

I am was unsure what number to put in `since = "-"` so I copied what someone had done in a recent PR.
  • Loading branch information
Centril authored Oct 28, 2019
2 parents 95f437b + 65af429 commit c8eefdf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
1 change: 0 additions & 1 deletion src/liballoc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![feature(drain_filter)]
#![feature(exact_size_is_empty)]
#![feature(new_uninit)]
#![feature(option_flattening)]
#![feature(pattern)]
#![feature(trusted_len)]
#![feature(try_reserve)]
Expand Down
4 changes: 1 addition & 3 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,6 @@ impl<T> Option<Option<T>> {
/// # Examples
/// Basic usage:
/// ```
/// #![feature(option_flattening)]
/// let x: Option<Option<u32>> = Some(Some(6));
/// assert_eq!(Some(6), x.flatten());
///
Expand All @@ -1579,13 +1578,12 @@ impl<T> Option<Option<T>> {
/// ```
/// Flattening once only removes one level of nesting:
/// ```
/// #![feature(option_flattening)]
/// let x: Option<Option<Option<u32>>> = Some(Some(Some(6)));
/// assert_eq!(Some(Some(6)), x.flatten());
/// assert_eq!(Some(6), x.flatten().flatten());
/// ```
#[inline]
#[unstable(feature = "option_flattening", issue = "60258")]
#[stable(feature = "option_flattening", since = "1.40.0")]
pub fn flatten(self) -> Option<T> {
self.and_then(convert::identity)
}
Expand Down

0 comments on commit c8eefdf

Please sign in to comment.