Skip to content

Commit

Permalink
std: Stabilize APIs for the 1.11.0 release
Browse files Browse the repository at this point in the history
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 rust-lang#27739
Closes rust-lang#27752
Closes rust-lang#32526
Closes rust-lang#33444
Closes rust-lang#34152
cc rust-lang#34529 (new tracking issue)
  • Loading branch information
alexcrichton committed Jul 3, 2016
1 parent 375fa6e commit 3016626
Show file tree
Hide file tree
Showing 36 changed files with 507 additions and 194 deletions.
6 changes: 1 addition & 5 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,6 @@ impl<T: Ord> BinaryHeap<T> {
/// Basic usage:
///
/// ```
/// #![feature(binary_heap_append)]
///
/// use std::collections::BinaryHeap;
///
/// let v = vec![-10, 1, 2, 3, 3];
Expand All @@ -840,9 +838,7 @@ impl<T: Ord> BinaryHeap<T> {
/// assert_eq!(a.into_sorted_vec(), [-20, -10, 1, 2, 3, 3, 5, 43]);
/// assert!(b.is_empty());
/// ```
#[unstable(feature = "binary_heap_append",
reason = "needs to be audited",
issue = "32526")]
#[stable(feature = "binary_heap_append", since = "1.11.0")]
pub fn append(&mut self, other: &mut Self) {
if self.len() < other.len() {
swap(self, other);
Expand Down
9 changes: 2 additions & 7 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,6 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// # Examples
///
/// ```
/// #![feature(btree_append)]
/// use std::collections::BTreeMap;
///
/// let mut a = BTreeMap::new();
Expand All @@ -583,8 +582,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// assert_eq!(a[&4], "e");
/// assert_eq!(a[&5], "f");
/// ```
#[unstable(feature = "btree_append", reason = "recently added as part of collections reform 2",
issue = "34152")]
#[stable(feature = "btree_append", since = "1.11.0")]
pub fn append(&mut self, other: &mut Self) {
// Do we have to append anything at all?
if other.len() == 0 {
Expand Down Expand Up @@ -914,7 +912,6 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// Basic usage:
///
/// ```
/// #![feature(btree_split_off)]
/// use std::collections::BTreeMap;
///
/// let mut a = BTreeMap::new();
Expand All @@ -936,9 +933,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// assert_eq!(b[&17], "d");
/// assert_eq!(b[&41], "e");
/// ```
#[unstable(feature = "btree_split_off",
reason = "recently added as part of collections reform 2",
issue = "34152")]
#[stable(feature = "btree_split_off", since = "1.11.0")]
pub fn split_off<Q: ?Sized + Ord>(&mut self, key: &Q) -> Self
where K: Borrow<Q>
{
Expand Down
9 changes: 2 additions & 7 deletions src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ impl<T: Ord> BTreeSet<T> {
/// # Examples
///
/// ```
/// #![feature(btree_append)]
/// use std::collections::BTreeSet;
///
/// let mut a = BTreeSet::new();
Expand All @@ -575,8 +574,7 @@ impl<T: Ord> BTreeSet<T> {
/// assert!(a.contains(&4));
/// assert!(a.contains(&5));
/// ```
#[unstable(feature = "btree_append", reason = "recently added as part of collections reform 2",
issue = "34152")]
#[stable(feature = "btree_append", since = "1.11.0")]
pub fn append(&mut self, other: &mut Self) {
self.map.append(&mut other.map);
}
Expand All @@ -589,7 +587,6 @@ impl<T: Ord> BTreeSet<T> {
/// Basic usage:
///
/// ```
/// #![feature(btree_split_off)]
/// use std::collections::BTreeMap;
///
/// let mut a = BTreeMap::new();
Expand All @@ -611,9 +608,7 @@ impl<T: Ord> BTreeSet<T> {
/// assert_eq!(b[&17], "d");
/// assert_eq!(b[&41], "e");
/// ```
#[unstable(feature = "btree_split_off",
reason = "recently added as part of collections reform 2",
issue = "34152")]
#[stable(feature = "btree_split_off", since = "1.11.0")]
pub fn split_off<Q: ?Sized + Ord>(&mut self, key: &Q) -> Self where T: Borrow<Q> {
BTreeSet { map: self.map.split_off(key) }
}
Expand Down
1 change: 0 additions & 1 deletion src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#![feature(fmt_internals)]
#![feature(heap_api)]
#![feature(inclusive_range)]
#![feature(iter_arith)]
#![feature(lang_items)]
#![feature(nonzero)]
#![feature(pattern)]
Expand Down
4 changes: 0 additions & 4 deletions src/libcollectionstest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@
#![deny(warnings)]

#![feature(binary_heap_extras)]
#![feature(binary_heap_append)]
#![feature(binary_heap_peek_mut)]
#![feature(box_syntax)]
#![feature(btree_append)]
#![feature(btree_split_off)]
#![feature(btree_range)]
#![feature(collections)]
#![feature(collections_bound)]
#![feature(const_fn)]
#![feature(fn_traits)]
#![feature(enumset)]
#![feature(iter_arith)]
#![feature(linked_list_contains)]
#![feature(pattern)]
#![feature(rand)]
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl<T:Copy> Cell<T> {
/// This call borrows `Cell` mutably (at compile-time) which guarantees
/// that we possess the only reference.
#[inline]
#[unstable(feature = "cell_get_mut", issue = "33444")]
#[stable(feature = "cell_get_mut", since = "1.11.0")]
pub fn get_mut(&mut self) -> &mut T {
unsafe {
&mut *self.value.get()
Expand Down Expand Up @@ -509,7 +509,7 @@ impl<T: ?Sized> RefCell<T> {
/// This call borrows `RefCell` mutably (at compile-time) so there is no
/// need for dynamic checks.
#[inline]
#[unstable(feature = "cell_get_mut", issue="33444")]
#[stable(feature = "cell_get_mut", since = "1.11.0")]
pub fn get_mut(&mut self) -> &mut T {
unsafe {
&mut *self.value.get()
Expand Down
50 changes: 26 additions & 24 deletions src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@
use clone::Clone;
use cmp::{Ord, PartialOrd, PartialEq, Ordering};
use default::Default;
use num::{Zero, One};
use ops::{Add, FnMut, Mul};
use ops::FnMut;
use option::Option::{self, Some, None};
use marker::Sized;

use super::{Chain, Cycle, Cloned, Enumerate, Filter, FilterMap, FlatMap, Fuse,
Inspect, Map, Peekable, Scan, Skip, SkipWhile, Take, TakeWhile, Rev,
Zip};
use super::{Chain, Cycle, Cloned, Enumerate, Filter, FilterMap, FlatMap, Fuse};
use super::{Inspect, Map, Peekable, Scan, Skip, SkipWhile, Take, TakeWhile, Rev};
use super::{Zip, Sum, Product};
use super::ChainState;
use super::{DoubleEndedIterator, ExactSizeIterator, Extend, FromIterator,
IntoIterator};
use super::ZipImpl;
use super::{DoubleEndedIterator, ExactSizeIterator, Extend, FromIterator};
use super::{IntoIterator, ZipImpl};

fn _assert_is_object_safe(_: &Iterator<Item=()>) {}

Expand Down Expand Up @@ -1820,50 +1818,54 @@ pub trait Iterator {
///
/// An empty iterator returns the zero value of the type.
///
/// # Panics
///
/// When calling `sum` and a primitive integer type is being returned, this
/// method will panic if the computation overflows.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(iter_arith)]
///
/// let a = [1, 2, 3];
/// let sum: i32 = a.iter().sum();
///
/// assert_eq!(sum, 6);
/// ```
#[unstable(feature = "iter_arith", reason = "bounds recently changed",
issue = "27739")]
fn sum<S>(self) -> S where
S: Add<Self::Item, Output=S> + Zero,
Self: Sized,
#[stable(feature = "iter_arith", since = "1.11.0")]
fn sum<S>(self) -> S
where Self: Sized,
S: Sum<Self::Item>,
{
self.fold(Zero::zero(), |s, e| s + e)
Sum::sum(self)
}

/// Iterates over the entire iterator, multiplying all the elements
///
/// An empty iterator returns the one value of the type.
///
/// # Panics
///
/// When calling `product` and a primitive integer type is being returned,
/// this method will panic if the computation overflows.
///
/// # Examples
///
/// ```
/// #![feature(iter_arith)]
///
/// fn factorial(n: u32) -> u32 {
/// (1..).take_while(|&i| i <= n).product()
/// }
/// assert_eq!(factorial(0), 1);
/// assert_eq!(factorial(1), 1);
/// assert_eq!(factorial(5), 120);
/// ```
#[unstable(feature="iter_arith", reason = "bounds recently changed",
issue = "27739")]
fn product<P>(self) -> P where
P: Mul<Self::Item, Output=P> + One,
Self: Sized,
#[stable(feature = "iter_arith", since = "1.11.0")]
fn product<P>(self) -> P
where Self: Sized,
P: Product<Self::Item>,
{
self.fold(One::one(), |p, e| p * e)
Product::product(self)
}

/// Lexicographically compares the elements of this `Iterator` with those
Expand Down
5 changes: 3 additions & 2 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,9 @@ pub use self::sources::{Empty, empty};
pub use self::sources::{Once, once};

#[stable(feature = "rust1", since = "1.0.0")]
pub use self::traits::{FromIterator, IntoIterator, DoubleEndedIterator, Extend,
ExactSizeIterator};
pub use self::traits::{FromIterator, IntoIterator, DoubleEndedIterator, Extend};
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::traits::{ExactSizeIterator, Sum, Product};

mod iterator;
mod range;
Expand Down
Loading

0 comments on commit 3016626

Please sign in to comment.