Skip to content

Commit

Permalink
Auto merge of #60377 - Centril:rollup-42fxe9u, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 9 pull requests

Successful merges:

 - #59946 (Fix equivalent string in escape_default docs)
 - #60256 (Option::flatten)
 - #60305 (hir: remove LoweredNodeId)
 - #60334 (Stabilized vectored IO)
 - #60353 (Add test not to forget resolved ICE)
 - #60356 (Stabilize str::as_mut_ptr)
 - #60358 (Clarify the short explanation of E0207)
 - #60359 (resolve: Consider erroneous imports used to avoid duplicate diagnostics)
 - #60360 (Add test case for labeled break in const assignment)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Apr 29, 2019
2 parents a55c2eb + 0494210 commit 00859e3
Show file tree
Hide file tree
Showing 56 changed files with 514 additions and 491 deletions.
32 changes: 31 additions & 1 deletion src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
#![stable(feature = "rust1", since = "1.0.0")]

use crate::iter::{FromIterator, FusedIterator, TrustedLen};
use crate::{hint, mem, ops::{self, Deref}};
use crate::{convert, hint, mem, ops::{self, Deref}};
use crate::pin::Pin;

// Note that this is not a lang item per se, but it has a hidden dependency on
Expand Down Expand Up @@ -1413,3 +1413,33 @@ impl<T> ops::Try for Option<T> {
None
}
}

impl<T> Option<Option<T>> {
/// Converts from `Option<Option<T>>` to `Option<T>`
///
/// # Examples
/// Basic usage:
/// ```
/// #![feature(option_flattening)]
/// let x: Option<Option<u32>> = Some(Some(6));
/// assert_eq!(Some(6), x.flatten());
///
/// let x: Option<Option<u32>> = Some(None);
/// assert_eq!(None, x.flatten());
///
/// let x: Option<Option<u32>> = None;
/// assert_eq!(None, x.flatten());
/// ```
/// 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")]
pub fn flatten(self) -> Option<T> {
self.and_then(convert::identity)
}
}
4 changes: 2 additions & 2 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2214,7 +2214,7 @@ impl str {
/// modified in a way that it remains valid UTF-8.
///
/// [`u8`]: primitive.u8.html
#[unstable(feature = "str_as_mut_ptr", issue = "58215")]
#[stable(feature = "str_as_mut_ptr", since = "1.36.0")]
#[inline]
pub fn as_mut_ptr(&mut self) -> *mut u8 {
self as *mut str as *mut u8
Expand Down Expand Up @@ -4061,7 +4061,7 @@ impl str {
/// Both are equivalent to:
///
/// ```
/// println!("\\u{{2764}}\n!");
/// println!("\\u{{2764}}\\n!");
/// ```
///
/// Using `to_string`:
Expand Down
Loading

0 comments on commit 00859e3

Please sign in to comment.