]> git.lizzy.rs Git - rust.git/commitdiff
Remove num::{Zero,One}
authorJosh Stone <jistone@redhat.com>
Thu, 20 Apr 2017 22:12:42 +0000 (15:12 -0700)
committerJosh Stone <jistone@redhat.com>
Fri, 21 Apr 2017 04:16:31 +0000 (21:16 -0700)
[unstable, deprecated since 1.11.0]

src/doc/unstable-book/src/SUMMARY.md
src/doc/unstable-book/src/library-features/zero-one.md [deleted file]
src/libcore/fmt/num.rs
src/libcore/num/mod.rs
src/libstd/lib.rs
src/libstd/num.rs
src/test/run-pass/issue-8460.rs

index ae3b23a33b24ee09f99b0279a2086af71d0f2d53..48659413cad0090e9d1af1adce9836d3b5887a2a 100644 (file)
     - [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.
diff --git a/src/doc/unstable-book/src/library-features/zero-one.md b/src/doc/unstable-book/src/library-features/zero-one.md
deleted file mode 100644 (file)
index 4d1cf38..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# `zero_one`
-
-The tracking issue for this feature is: [#27739]
-
-[#27739]: https://github.com/rust-lang/rust/issues/27739
-
-------------------------
index a324a4aed25766da158a71c31bbf098a75462791..4ca303dee43f2ad600237d82680c0a6ddfa6d0f7 100644 (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 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 }
index f665cfdee77aeaaaadc9513dda03b45fac286578..1e25d45bfbb5129091ca0987fdbb7abd82b82846 100644 (file)
@@ -96,78 +96,6 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 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) };
index 6c3abf99d11fa4644662c9ffe20932908bc7ab35..28b94107c425abb3e5f12409f85eebc163365e14 100644 (file)
 #![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))]
index 5f83d077a13682897b570234ca23ae77b10520c1..ff89887ac92c3c59369a75ffcf5e9df20d3f224e 100644 (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")]
index 5148be5af8307b208c504157c5eab6756e1312ba..17ea5b9a79489855c314adc38a5f985f53c5f5d5 100644 (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(),