Stabilize the map
/value
methods on ControlFlow
And fix the stability attribute on the `pub use` in `core::ops`.
This commit is contained in:
parent
9e394f551c
commit
fd5aa07f4f
@ -5,7 +5,6 @@
|
|||||||
#![doc(rust_logo)]
|
#![doc(rust_logo)]
|
||||||
#![feature(assert_matches)]
|
#![feature(assert_matches)]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(control_flow_enum)]
|
|
||||||
#![feature(file_buffered)]
|
#![feature(file_buffered)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
|
@ -63,7 +63,6 @@
|
|||||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||||
#![doc(rust_logo)]
|
#![doc(rust_logo)]
|
||||||
#![feature(assert_matches)]
|
#![feature(assert_matches)]
|
||||||
#![feature(control_flow_enum)]
|
|
||||||
#![feature(if_let_guard)]
|
#![feature(if_let_guard)]
|
||||||
#![feature(iter_intersperse)]
|
#![feature(iter_intersperse)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#![allow(rustc::untranslatable_diagnostic)]
|
#![allow(rustc::untranslatable_diagnostic)]
|
||||||
#![feature(array_windows)]
|
#![feature(array_windows)]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(control_flow_enum)]
|
|
||||||
#![feature(if_let_guard)]
|
#![feature(if_let_guard)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#![doc(rust_logo)]
|
#![doc(rust_logo)]
|
||||||
#![feature(assert_matches)]
|
#![feature(assert_matches)]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(control_flow_enum)]
|
|
||||||
#![feature(extend_one)]
|
#![feature(extend_one)]
|
||||||
#![feature(if_let_guard)]
|
#![feature(if_let_guard)]
|
||||||
#![feature(iter_intersperse)]
|
#![feature(iter_intersperse)]
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#![feature(array_windows)]
|
#![feature(array_windows)]
|
||||||
#![feature(assert_matches)]
|
#![feature(assert_matches)]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(control_flow_enum)]
|
|
||||||
#![feature(extract_if)]
|
#![feature(extract_if)]
|
||||||
#![feature(if_let_guard)]
|
#![feature(if_let_guard)]
|
||||||
#![feature(iter_order_by)]
|
#![feature(iter_order_by)]
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#![allow(rustc::potential_query_instability)]
|
#![allow(rustc::potential_query_instability)]
|
||||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||||
#![doc(rust_logo)]
|
#![doc(rust_logo)]
|
||||||
#![feature(control_flow_enum)]
|
|
||||||
#![feature(coroutines)]
|
#![feature(coroutines)]
|
||||||
#![feature(decl_macro)]
|
#![feature(decl_macro)]
|
||||||
#![feature(error_iter)]
|
#![feature(error_iter)]
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#![feature(associated_type_defaults)]
|
#![feature(associated_type_defaults)]
|
||||||
#![feature(box_patterns)]
|
#![feature(box_patterns)]
|
||||||
#![feature(cfg_version)]
|
#![feature(cfg_version)]
|
||||||
#![feature(control_flow_enum)]
|
|
||||||
#![feature(extract_if)]
|
#![feature(extract_if)]
|
||||||
#![feature(if_let_guard)]
|
#![feature(if_let_guard)]
|
||||||
#![feature(iter_intersperse)]
|
#![feature(iter_intersperse)]
|
||||||
|
@ -171,14 +171,13 @@ pub fn is_continue(&self) -> bool {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(control_flow_enum)]
|
|
||||||
/// use std::ops::ControlFlow;
|
/// use std::ops::ControlFlow;
|
||||||
///
|
///
|
||||||
/// assert_eq!(ControlFlow::<i32, String>::Break(3).break_value(), Some(3));
|
/// assert_eq!(ControlFlow::<i32, String>::Break(3).break_value(), Some(3));
|
||||||
/// assert_eq!(ControlFlow::<String, i32>::Continue(3).break_value(), None);
|
/// assert_eq!(ControlFlow::<String, i32>::Continue(3).break_value(), None);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
#[stable(feature = "control_flow_enum", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn break_value(self) -> Option<B> {
|
pub fn break_value(self) -> Option<B> {
|
||||||
match self {
|
match self {
|
||||||
ControlFlow::Continue(..) => None,
|
ControlFlow::Continue(..) => None,
|
||||||
@ -189,11 +188,8 @@ pub fn break_value(self) -> Option<B> {
|
|||||||
/// Maps `ControlFlow<B, C>` to `ControlFlow<T, C>` by applying a function
|
/// Maps `ControlFlow<B, C>` to `ControlFlow<T, C>` by applying a function
|
||||||
/// to the break value in case it exists.
|
/// to the break value in case it exists.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
#[stable(feature = "control_flow_enum", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn map_break<T, F>(self, f: F) -> ControlFlow<T, C>
|
pub fn map_break<T>(self, f: impl FnOnce(B) -> T) -> ControlFlow<T, C> {
|
||||||
where
|
|
||||||
F: FnOnce(B) -> T,
|
|
||||||
{
|
|
||||||
match self {
|
match self {
|
||||||
ControlFlow::Continue(x) => ControlFlow::Continue(x),
|
ControlFlow::Continue(x) => ControlFlow::Continue(x),
|
||||||
ControlFlow::Break(x) => ControlFlow::Break(f(x)),
|
ControlFlow::Break(x) => ControlFlow::Break(f(x)),
|
||||||
@ -206,14 +202,13 @@ pub fn map_break<T, F>(self, f: F) -> ControlFlow<T, C>
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(control_flow_enum)]
|
|
||||||
/// use std::ops::ControlFlow;
|
/// use std::ops::ControlFlow;
|
||||||
///
|
///
|
||||||
/// assert_eq!(ControlFlow::<i32, String>::Break(3).continue_value(), None);
|
/// assert_eq!(ControlFlow::<i32, String>::Break(3).continue_value(), None);
|
||||||
/// assert_eq!(ControlFlow::<String, i32>::Continue(3).continue_value(), Some(3));
|
/// assert_eq!(ControlFlow::<String, i32>::Continue(3).continue_value(), Some(3));
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
#[stable(feature = "control_flow_enum", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn continue_value(self) -> Option<C> {
|
pub fn continue_value(self) -> Option<C> {
|
||||||
match self {
|
match self {
|
||||||
ControlFlow::Continue(x) => Some(x),
|
ControlFlow::Continue(x) => Some(x),
|
||||||
@ -224,11 +219,8 @@ pub fn continue_value(self) -> Option<C> {
|
|||||||
/// Maps `ControlFlow<B, C>` to `ControlFlow<B, T>` by applying a function
|
/// Maps `ControlFlow<B, C>` to `ControlFlow<B, T>` by applying a function
|
||||||
/// to the continue value in case it exists.
|
/// to the continue value in case it exists.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
#[stable(feature = "control_flow_enum", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn map_continue<T, F>(self, f: F) -> ControlFlow<B, T>
|
pub fn map_continue<T>(self, f: impl FnOnce(C) -> T) -> ControlFlow<B, T> {
|
||||||
where
|
|
||||||
F: FnOnce(C) -> T,
|
|
||||||
{
|
|
||||||
match self {
|
match self {
|
||||||
ControlFlow::Continue(x) => ControlFlow::Continue(f(x)),
|
ControlFlow::Continue(x) => ControlFlow::Continue(f(x)),
|
||||||
ControlFlow::Break(x) => ControlFlow::Break(x),
|
ControlFlow::Break(x) => ControlFlow::Break(x),
|
||||||
|
@ -162,7 +162,7 @@
|
|||||||
pub use self::bit::{BitAnd, BitOr, BitXor, Not, Shl, Shr};
|
pub use self::bit::{BitAnd, BitOr, BitXor, Not, Shl, Shr};
|
||||||
#[stable(feature = "op_assign_traits", since = "1.8.0")]
|
#[stable(feature = "op_assign_traits", since = "1.8.0")]
|
||||||
pub use self::bit::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign};
|
pub use self::bit::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign};
|
||||||
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
|
#[stable(feature = "control_flow_enum_type", since = "1.55.0")]
|
||||||
pub use self::control_flow::ControlFlow;
|
pub use self::control_flow::ControlFlow;
|
||||||
#[unstable(feature = "coroutine_trait", issue = "43122")]
|
#[unstable(feature = "coroutine_trait", issue = "43122")]
|
||||||
pub use self::coroutine::{Coroutine, CoroutineState};
|
pub use self::coroutine::{Coroutine, CoroutineState};
|
||||||
|
Loading…
Reference in New Issue
Block a user