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:
Jacob Pratt 2021-04-02 01:05:43 -04:00
parent bc2f0fb5a9
commit 35ce36812a
No known key found for this signature in database
GPG Key ID: B80E19E4662B5AA4
4 changed files with 1 additions and 9 deletions

View File

@ -65,7 +65,7 @@ fn index(self) -> usize {
/// `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 ----

View File

@ -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 @@ fn forward(start: Self, count: usize) -> Self {
/// 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 @@ unsafe fn forward_unchecked(start: Self, count: usize) -> Self {
///
/// * `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 @@ unsafe fn forward_unchecked(start: Self, count: usize) -> Self {
/// * 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 @@ fn backward(start: Self, count: usize) -> Self {
/// 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)
}

View File

@ -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)]

View File

@ -3,7 +3,6 @@
#![feature(fn_traits,
step_trait,
step_trait_ext,
unboxed_closures,
)]