From 232424d9952700682373ccf2d578109f401ff023 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Thu, 19 Mar 2015 23:42:18 -0700 Subject: Stabilize std::num This commit stabilizes the `std::num` module: * The `Int` and `Float` traits are deprecated in favor of (1) the newly-added inherent methods and (2) the generic traits available in rust-lang/num. * The `Zero` and `One` traits are reintroduced in `std::num`, which together with various other traits allow you to recover the most common forms of generic programming. * The `FromStrRadix` trait, and associated free function, is deprecated in favor of inherent implementations. * A wide range of methods and constants for both integers and floating point numbers are now `#[stable]`, having been adjusted for integer guidelines. * `is_positive` and `is_negative` are renamed to `is_sign_positive` and `is_sign_negative`, in order to address #22985 * The `Wrapping` type is moved to `std::num` and stabilized; `WrappingOps` is deprecated in favor of inherent methods on the integer types, and direct implementation of operations on `Wrapping` for each concrete integer type `X`. Closes #22985 Closes #21069 [breaking-change] --- src/libstd/sys/common/mod.rs | 1 + src/libstd/sys/common/wtf8.rs | 1 + src/libstd/sys/unix/mod.rs | 2 ++ src/libstd/sys/windows/mod.rs | 2 ++ src/libstd/sys/windows/net.rs | 3 +++ 5 files changed, 9 insertions(+) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/common/mod.rs b/src/libstd/sys/common/mod.rs index a8769ba99e8..d2e2f1044d6 100644 --- a/src/libstd/sys/common/mod.rs +++ b/src/libstd/sys/common/mod.rs @@ -14,6 +14,7 @@ use old_io::{self, IoError, IoResult}; use prelude::v1::*; use sys::{last_error, retry}; use ffi::CString; +#[allow(deprecated)] // Int use num::Int; #[allow(deprecated)] diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 315df411179..91aa0622e5a 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -37,6 +37,7 @@ use fmt; use hash::{Hash, Hasher}; use iter::{FromIterator, IntoIterator}; use mem; +#[allow(deprecated)] // Int use num::Int; use ops; use slice; diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 5555eec4f39..e8409bb4fd4 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -171,6 +171,7 @@ pub fn retry (mut f: F) -> T where } } +#[allow(deprecated)] pub fn cvt(t: T) -> io::Result { let one: T = Int::one(); if t == -one { @@ -180,6 +181,7 @@ pub fn cvt(t: T) -> io::Result { } } +#[allow(deprecated)] pub fn cvt_r(mut f: F) -> io::Result where T: SignedInt, F: FnMut() -> T { diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs index b1ceac9b902..e9d5fca531f 100644 --- a/src/libstd/sys/windows/mod.rs +++ b/src/libstd/sys/windows/mod.rs @@ -18,6 +18,7 @@ use ffi::{OsStr, OsString}; use io::{self, ErrorKind}; use libc; use mem; +#[allow(deprecated)] use num::Int; use old_io::{self, IoResult, IoError}; use os::windows::ffi::{OsStrExt, OsStringExt}; @@ -315,6 +316,7 @@ pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] { } } +#[allow(deprecated)] fn cvt(i: I) -> io::Result { if i == Int::zero() { Err(io::Error::last_os_error()) diff --git a/src/libstd/sys/windows/net.rs b/src/libstd/sys/windows/net.rs index 734268c70ac..88d043de479 100644 --- a/src/libstd/sys/windows/net.rs +++ b/src/libstd/sys/windows/net.rs @@ -15,6 +15,7 @@ use libc::consts::os::extra::INVALID_SOCKET; use libc::{self, c_int, c_void}; use mem; use net::SocketAddr; +#[allow(deprecated)] use num::{SignedInt, Int}; use rt; use sync::{Once, ONCE_INIT}; @@ -50,6 +51,7 @@ fn last_error() -> io::Error { /// function must be called before another call to the socket API is made. /// /// FIXME: generics needed? +#[allow(deprecated)] pub fn cvt(t: T) -> io::Result { let one: T = Int::one(); if t == -one { @@ -67,6 +69,7 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> { } /// Provides the functionality of `cvt` for a closure. +#[allow(deprecated)] pub fn cvt_r(mut f: F) -> io::Result where F: FnMut() -> T { cvt(f()) } -- cgit 1.4.1-3-g733a5