Skip to content

Commit 00859e3

Browse files
committed
Auto merge of #60377 - Centril:rollup-42fxe9u, r=Centril
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
2 parents a55c2eb + 0494210 commit 00859e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+514
-491
lines changed

src/libcore/option.rs

+31-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
#![stable(feature = "rust1", since = "1.0.0")]
137137

138138
use crate::iter::{FromIterator, FusedIterator, TrustedLen};
139-
use crate::{hint, mem, ops::{self, Deref}};
139+
use crate::{convert, hint, mem, ops::{self, Deref}};
140140
use crate::pin::Pin;
141141

142142
// Note that this is not a lang item per se, but it has a hidden dependency on
@@ -1413,3 +1413,33 @@ impl<T> ops::Try for Option<T> {
14131413
None
14141414
}
14151415
}
1416+
1417+
impl<T> Option<Option<T>> {
1418+
/// Converts from `Option<Option<T>>` to `Option<T>`
1419+
///
1420+
/// # Examples
1421+
/// Basic usage:
1422+
/// ```
1423+
/// #![feature(option_flattening)]
1424+
/// let x: Option<Option<u32>> = Some(Some(6));
1425+
/// assert_eq!(Some(6), x.flatten());
1426+
///
1427+
/// let x: Option<Option<u32>> = Some(None);
1428+
/// assert_eq!(None, x.flatten());
1429+
///
1430+
/// let x: Option<Option<u32>> = None;
1431+
/// assert_eq!(None, x.flatten());
1432+
/// ```
1433+
/// Flattening once only removes one level of nesting:
1434+
/// ```
1435+
/// #![feature(option_flattening)]
1436+
/// let x: Option<Option<Option<u32>>> = Some(Some(Some(6)));
1437+
/// assert_eq!(Some(Some(6)), x.flatten());
1438+
/// assert_eq!(Some(6), x.flatten().flatten());
1439+
/// ```
1440+
#[inline]
1441+
#[unstable(feature = "option_flattening", issue = "60258")]
1442+
pub fn flatten(self) -> Option<T> {
1443+
self.and_then(convert::identity)
1444+
}
1445+
}

src/libcore/str/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ impl str {
22142214
/// modified in a way that it remains valid UTF-8.
22152215
///
22162216
/// [`u8`]: primitive.u8.html
2217-
#[unstable(feature = "str_as_mut_ptr", issue = "58215")]
2217+
#[stable(feature = "str_as_mut_ptr", since = "1.36.0")]
22182218
#[inline]
22192219
pub fn as_mut_ptr(&mut self) -> *mut u8 {
22202220
self as *mut str as *mut u8
@@ -4061,7 +4061,7 @@ impl str {
40614061
/// Both are equivalent to:
40624062
///
40634063
/// ```
4064-
/// println!("\\u{{2764}}\n!");
4064+
/// println!("\\u{{2764}}\\n!");
40654065
/// ```
40664066
///
40674067
/// Using `to_string`:

0 commit comments

Comments
 (0)