mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Unify feature flags as step_trait
While stdlib implementations of the unchecked methods require unchecked math, there is no reason to gate it behind this for external users. The reasoning for a separate `step_trait_ext` feature is unclear, and as such has been merged as well.
This commit is contained in:
parent
bc2f0fb5a9
commit
35ce36812a
@ -65,7 +65,7 @@ impl Idx for u32 {
|
||||
/// `u32::MAX`. You can also customize things like the `Debug` impl,
|
||||
/// what traits are derived, and so forth via the macro.
|
||||
#[macro_export]
|
||||
#[allow_internal_unstable(step_trait, step_trait_ext, rustc_attrs)]
|
||||
#[allow_internal_unstable(step_trait, rustc_attrs)]
|
||||
macro_rules! newtype_index {
|
||||
// ---- public rules ----
|
||||
|
||||
|
@ -57,7 +57,6 @@ pub trait Step: Clone + PartialOrd + Sized {
|
||||
///
|
||||
/// * `Step::forward_checked(a, n) == (0..n).try_fold(a, |x, _| Step::forward_checked(&x, 1))`
|
||||
/// * Corollary: `Step::forward_checked(&a, 0) == Some(a)`
|
||||
#[unstable(feature = "step_trait_ext", reason = "recently added", issue = "42168")]
|
||||
fn forward_checked(start: Self, count: usize) -> Option<Self>;
|
||||
|
||||
/// Returns the value that would be obtained by taking the *successor*
|
||||
@ -83,7 +82,6 @@ pub trait Step: Clone + PartialOrd + Sized {
|
||||
/// * Corollary: `Step::forward(a, 0) == a`
|
||||
/// * `Step::forward(a, n) >= a`
|
||||
/// * `Step::backward(Step::forward(a, n), n) == a`
|
||||
#[unstable(feature = "step_trait_ext", reason = "recently added", issue = "42168")]
|
||||
fn forward(start: Self, count: usize) -> Self {
|
||||
Step::forward_checked(start, count).expect("overflow in `Step::forward`")
|
||||
}
|
||||
@ -108,7 +106,6 @@ pub trait Step: Clone + PartialOrd + Sized {
|
||||
/// For any `a` and `n`, where no overflow occurs:
|
||||
///
|
||||
/// * `Step::forward_unchecked(a, n)` is equivalent to `Step::forward(a, n)`
|
||||
#[unstable(feature = "step_trait_ext", reason = "recently added", issue = "42168")]
|
||||
unsafe fn forward_unchecked(start: Self, count: usize) -> Self {
|
||||
Step::forward(start, count)
|
||||
}
|
||||
@ -129,7 +126,6 @@ pub trait Step: Clone + PartialOrd + Sized {
|
||||
///
|
||||
/// * `Step::backward_checked(a, n) == (0..n).try_fold(a, |x, _| Step::backward_checked(&x, 1))`
|
||||
/// * Corollary: `Step::backward_checked(&a, 0) == Some(a)`
|
||||
#[unstable(feature = "step_trait_ext", reason = "recently added", issue = "42168")]
|
||||
fn backward_checked(start: Self, count: usize) -> Option<Self>;
|
||||
|
||||
/// Returns the value that would be obtained by taking the *predecessor*
|
||||
@ -155,7 +151,6 @@ pub trait Step: Clone + PartialOrd + Sized {
|
||||
/// * Corollary: `Step::backward(a, 0) == a`
|
||||
/// * `Step::backward(a, n) <= a`
|
||||
/// * `Step::forward(Step::backward(a, n), n) == a`
|
||||
#[unstable(feature = "step_trait_ext", reason = "recently added", issue = "42168")]
|
||||
fn backward(start: Self, count: usize) -> Self {
|
||||
Step::backward_checked(start, count).expect("overflow in `Step::backward`")
|
||||
}
|
||||
@ -180,7 +175,6 @@ pub trait Step: Clone + PartialOrd + Sized {
|
||||
/// For any `a` and `n`, where no overflow occurs:
|
||||
///
|
||||
/// * `Step::backward_unchecked(a, n)` is equivalent to `Step::backward(a, n)`
|
||||
#[unstable(feature = "step_trait_ext", reason = "recently added", issue = "42168")]
|
||||
unsafe fn backward_unchecked(start: Self, count: usize) -> Self {
|
||||
Step::backward(start, count)
|
||||
}
|
||||
|
@ -40,7 +40,6 @@
|
||||
#![feature(maybe_uninit_write_slice)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(step_trait)]
|
||||
#![feature(step_trait_ext)]
|
||||
#![feature(str_internals)]
|
||||
#![feature(test)]
|
||||
#![feature(trusted_len)]
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#![feature(fn_traits,
|
||||
step_trait,
|
||||
step_trait_ext,
|
||||
unboxed_closures,
|
||||
)]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user