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)
This commit is contained in:
parent
375fa6ef37
commit
3016626c3a
36 changed files with 507 additions and 194 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue