diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-06-28 08:56:56 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-07-03 10:49:01 -0700 |
| commit | 3016626c3aa4bc44807e54a8ba8b9e367ff566f5 (patch) | |
| tree | 4dd6d30026ff2b9af406e1923e9f954da8e62690 /src/libstd/sys/unix | |
| parent | 375fa6ef371a0ae248968d363226101ef741127e (diff) | |
| download | rust-3016626c3aa4bc44807e54a8ba8b9e367ff566f5.tar.gz rust-3016626c3aa4bc44807e54a8ba8b9e367ff566f5.zip | |
std: Stabilize APIs for the 1.11.0 release
Although the set of APIs being stabilized this release is relatively small, the
trains keep going! Listed below are the APIs in the standard library which have
either transitioned from unstable to stable or those from unstable to
deprecated.
Stable
* `BTreeMap::{append, split_off}`
* `BTreeSet::{append, split_off}`
* `Cell::get_mut`
* `RefCell::get_mut`
* `BinaryHeap::append`
* `{f32, f64}::{to_degrees, to_radians}` - libcore stabilizations mirroring past
libstd stabilizations
* `Iterator::sum`
* `Iterator::product`
Deprecated
* `{f32, f64}::next_after`
* `{f32, f64}::integer_decode`
* `{f32, f64}::ldexp`
* `{f32, f64}::frexp`
* `num::One`
* `num::Zero`
Added APIs (all unstable)
* `iter::Sum`
* `iter::Product`
* `iter::Step` - a few methods were added to accomodate deprecation of One/Zero
Removed APIs
* `From<Range<T>> for RangeInclusive<T>` - everything about `RangeInclusive` is
unstable
Closes #27739
Closes #27752
Closes #32526
Closes #33444
Closes #34152
cc #34529 (new tracking issue)
Diffstat (limited to 'src/libstd/sys/unix')
| -rw-r--r-- | src/libstd/sys/unix/mod.rs | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/libstd/sys/unix/mod.rs b/src/libstd/sys/unix/mod.rs index 12a877f7478..f0fd42fc99b 100644 --- a/src/libstd/sys/unix/mod.rs +++ b/src/libstd/sys/unix/mod.rs @@ -12,8 +12,6 @@ use io::{self, ErrorKind}; use libc; -use num::One; -use ops::Neg; #[cfg(target_os = "android")] pub use os::android as platform; #[cfg(target_os = "bitrig")] pub use os::bitrig as platform; @@ -123,9 +121,23 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { } } -pub fn cvt<T: One + PartialEq + Neg<Output=T>>(t: T) -> io::Result<T> { - let one: T = T::one(); - if t == -one { +#[doc(hidden)] +pub trait IsMinusOne { + fn is_minus_one(&self) -> bool; +} + +macro_rules! impl_is_minus_one { + ($($t:ident)*) => ($(impl IsMinusOne for $t { + fn is_minus_one(&self) -> bool { + *self == -1 + } + })*) +} + +impl_is_minus_one! { i8 i16 i32 i64 isize } + +pub fn cvt<T: IsMinusOne>(t: T) -> io::Result<T> { + if t.is_minus_one() { Err(io::Error::last_os_error()) } else { Ok(t) @@ -133,7 +145,8 @@ pub fn cvt<T: One + PartialEq + Neg<Output=T>>(t: T) -> io::Result<T> { } pub fn cvt_r<T, F>(mut f: F) -> io::Result<T> - where T: One + PartialEq + Neg<Output=T>, F: FnMut() -> T + where T: IsMinusOne, + F: FnMut() -> T { loop { match cvt(f()) { |
