Remove num::{Zero,One}

[unstable, deprecated since 1.11.0]
This commit is contained in:
Josh Stone 2017-04-20 15:12:42 -07:00
parent 313aab8fbe
commit c903ac64e5
7 changed files with 26 additions and 99 deletions

View File

@ -217,5 +217,3 @@
- [windows_handle](library-features/windows-handle.md)
- [windows_net](library-features/windows-net.md)
- [windows_stdio](library-features/windows-stdio.md)
- [zero_one](library-features/zero-one.md)
>>>>>> Add top level sections to the Unstable Book.

View File

@ -1,7 +0,0 @@
# `zero_one`
The tracking issue for this feature is: [#27739]
[#27739]: https://github.com/rust-lang/rust/issues/27739
------------------------

View File

@ -15,7 +15,6 @@
// FIXME: #6220 Implement floating point formatting
use fmt;
use num::Zero;
use ops::{Div, Rem, Sub};
use str;
use slice;
@ -23,8 +22,9 @@ use ptr;
use mem;
#[doc(hidden)]
trait Int: Zero + PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
trait Int: PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
Sub<Output=Self> + Copy {
fn zero() -> Self;
fn from_u8(u: u8) -> Self;
fn to_u8(&self) -> u8;
fn to_u16(&self) -> u16;
@ -35,6 +35,7 @@ trait Int: Zero + PartialEq + PartialOrd + Div<Output=Self> + Rem<Output=Self> +
macro_rules! doit {
($($t:ident)*) => ($(impl Int for $t {
fn zero() -> $t { 0 }
fn from_u8(u: u8) -> $t { u as $t }
fn to_u8(&self) -> u8 { *self as u8 }
fn to_u16(&self) -> u16 { *self as u16 }

View File

@ -96,78 +96,6 @@ pub mod dec2flt;
pub mod bignum;
pub mod diy_float;
/// Types that have a "zero" value.
///
/// This trait is intended for use in conjunction with `Add`, as an identity:
/// `x + T::zero() == x`.
#[unstable(feature = "zero_one",
reason = "unsure of placement, wants to use associated constants",
issue = "27739")]
#[rustc_deprecated(since = "1.11.0", reason = "no longer used for \
Iterator::sum")]
pub trait Zero: Sized {
/// The "zero" (usually, additive identity) for this type.
fn zero() -> Self;
}
/// Types that have a "one" value.
///
/// This trait is intended for use in conjunction with `Mul`, as an identity:
/// `x * T::one() == x`.
#[unstable(feature = "zero_one",
reason = "unsure of placement, wants to use associated constants",
issue = "27739")]
#[rustc_deprecated(since = "1.11.0", reason = "no longer used for \
Iterator::product")]
pub trait One: Sized {
/// The "one" (usually, multiplicative identity) for this type.
fn one() -> Self;
}
macro_rules! zero_one_impl {
($($t:ty)*) => ($(
#[unstable(feature = "zero_one",
reason = "unsure of placement, wants to use associated constants",
issue = "27739")]
#[allow(deprecated)]
impl Zero for $t {
#[inline]
fn zero() -> Self { 0 }
}
#[unstable(feature = "zero_one",
reason = "unsure of placement, wants to use associated constants",
issue = "27739")]
#[allow(deprecated)]
impl One for $t {
#[inline]
fn one() -> Self { 1 }
}
)*)
}
zero_one_impl! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
macro_rules! zero_one_impl_float {
($($t:ty)*) => ($(
#[unstable(feature = "zero_one",
reason = "unsure of placement, wants to use associated constants",
issue = "27739")]
#[allow(deprecated)]
impl Zero for $t {
#[inline]
fn zero() -> Self { 0.0 }
}
#[unstable(feature = "zero_one",
reason = "unsure of placement, wants to use associated constants",
issue = "27739")]
#[allow(deprecated)]
impl One for $t {
#[inline]
fn one() -> Self { 1.0 }
}
)*)
}
zero_one_impl_float! { f32 f64 }
macro_rules! checked_op {
($U:ty, $op:path, $x:expr, $y:expr) => {{
let (result, overflowed) = unsafe { $op($x as $U, $y as $U) };

View File

@ -318,7 +318,6 @@
#![feature(untagged_unions)]
#![feature(unwind_attributes)]
#![feature(vec_push_all)]
#![feature(zero_one)]
#![cfg_attr(test, feature(update_panic_count))]
#![cfg_attr(stage0, feature(pub_restricted))]
#![cfg_attr(test, feature(float_bits_conv))]

View File

@ -16,9 +16,6 @@
#![stable(feature = "rust1", since = "1.0.0")]
#![allow(missing_docs)]
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub use core::num::{Zero, One};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError};
#[stable(feature = "rust1", since = "1.0.0")]

View File

@ -9,11 +9,22 @@
// except according to those terms.
// ignore-emscripten no threads support
#![feature(rustc_attrs, zero_one)]
#![feature(rustc_attrs)]
use std::num::Zero;
use std::thread;
trait Int {
fn zero() -> Self;
fn one() -> Self;
}
macro_rules! doit {
($($t:ident)*) => ($(impl Int for $t {
fn zero() -> $t { 0 }
fn one() -> $t { 1 }
})*)
}
doit! { i8 i16 i32 i64 isize }
macro_rules! check {
($($e:expr),*) => {
$(assert!(thread::spawn({
@ -24,21 +35,21 @@ macro_rules! check {
fn main() {
check![
isize::min_value() / -1,
i8::min_value() / -1,
i16::min_value() / -1,
i32::min_value() / -1,
i64::min_value() / -1,
isize::min_value() / -isize::one(),
i8::min_value() / -i8::one(),
i16::min_value() / -i16::one(),
i32::min_value() / -i32::one(),
i64::min_value() / -i64::one(),
1isize / isize::zero(),
1i8 / i8::zero(),
1i16 / i16::zero(),
1i32 / i32::zero(),
1i64 / i64::zero(),
isize::min_value() % -1,
i8::min_value() % -1,
i16::min_value() % -1,
i32::min_value() % -1,
i64::min_value() % -1,
isize::min_value() % -isize::one(),
i8::min_value() % -i8::one(),
i16::min_value() % -i16::one(),
i32::min_value() % -i32::one(),
i64::min_value() % -i64::one(),
1isize % isize::zero(),
1i8 % i8::zero(),
1i16 % i16::zero(),