Skip to content

Commit

Permalink
rollup merge of rust-lang#20560: aturon/stab-2-iter-ops-slice
Browse files Browse the repository at this point in the history
Conflicts:
	src/libcollections/slice.rs
	src/libcore/iter.rs
	src/libstd/sync/mpsc/mod.rs
	src/libstd/sync/rwlock.rs
  • Loading branch information
alexcrichton committed Jan 6, 2015
2 parents bb5e16b + c6f4a03 commit 2e883a5
Show file tree
Hide file tree
Showing 32 changed files with 574 additions and 362 deletions.
6 changes: 3 additions & 3 deletions src/liballoc/arc.rs
Expand Up @@ -246,7 +246,7 @@ impl<T> BorrowFrom<Arc<T>> for T {
}
}

#[experimental = "Deref is experimental."]
#[stable]
impl<T> Deref for Arc<T> {
type Target = T;

Expand Down Expand Up @@ -290,7 +290,7 @@ impl<T: Send + Sync + Clone> Arc<T> {
}

#[unsafe_destructor]
#[experimental = "waiting on stability of Drop"]
#[stable]
impl<T: Sync + Send> Drop for Arc<T> {
/// Drops the `Arc<T>`.
///
Expand Down Expand Up @@ -418,7 +418,7 @@ impl<T: Sync + Send> Clone for Weak<T> {
}

#[unsafe_destructor]
#[experimental = "Weak pointers may not belong in this module."]
#[stable]
impl<T: Sync + Send> Drop for Weak<T> {
/// Drops the `Weak<T>`.
///
Expand Down
2 changes: 2 additions & 0 deletions src/liballoc/boxed.rs
Expand Up @@ -155,12 +155,14 @@ impl fmt::Show for Box<Any> {
}
}

#[stable]
impl<Sized? T> Deref for Box<T> {
type Target = T;

fn deref(&self) -> &T { &**self }
}

#[stable]
impl<Sized? T> DerefMut for Box<T> {
fn deref_mut(&mut self) -> &mut T { &mut **self }
}
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/rc.rs
Expand Up @@ -354,7 +354,7 @@ impl<T> BorrowFrom<Rc<T>> for T {
}
}

#[experimental = "Deref is experimental."]
#[stable]
impl<T> Deref for Rc<T> {
type Target = T;

Expand All @@ -365,7 +365,7 @@ impl<T> Deref for Rc<T> {
}

#[unsafe_destructor]
#[experimental = "Drop is experimental."]
#[stable]
impl<T> Drop for Rc<T> {
/// Drops the `Rc<T>`.
///
Expand Down Expand Up @@ -656,7 +656,7 @@ impl<T> Weak<T> {
}

#[unsafe_destructor]
#[experimental = "Weak pointers may not belong in this module."]
#[stable]
impl<T> Drop for Weak<T> {
/// Drops the `Weak<T>`.
///
Expand Down
5 changes: 5 additions & 0 deletions src/libcollections/binary_heap.rs
Expand Up @@ -148,6 +148,7 @@
//! ```

#![allow(missing_docs)]
#![stable]

use core::prelude::*;

Expand Down Expand Up @@ -561,11 +562,13 @@ impl<T: Ord> BinaryHeap<T> {
}

/// `BinaryHeap` iterator.
#[stable]
pub struct Iter <'a, T: 'a> {
iter: slice::Iter<'a, T>,
}

// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
#[stable]
impl<'a, T> Clone for Iter<'a, T> {
fn clone(&self) -> Iter<'a, T> {
Iter { iter: self.iter.clone() }
Expand Down Expand Up @@ -593,6 +596,7 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
impl<'a, T> ExactSizeIterator for Iter<'a, T> {}

/// An iterator that moves out of a `BinaryHeap`.
#[stable]
pub struct IntoIter<T> {
iter: vec::IntoIter<T>,
}
Expand All @@ -618,6 +622,7 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
impl<T> ExactSizeIterator for IntoIter<T> {}

/// An iterator that drains a `BinaryHeap`.
#[unstable = "recent addition"]
pub struct Drain<'a, T: 'a> {
iter: vec::Drain<'a, T>,
}
Expand Down
2 changes: 2 additions & 0 deletions src/libcollections/dlist.rs
Expand Up @@ -19,6 +19,8 @@
// Backlinks over DList::prev are raw pointers that form a full chain in
// the reverse direction.

#![stable]

use core::prelude::*;

use alloc::boxed::Box;
Expand Down
7 changes: 5 additions & 2 deletions src/libcollections/lib.rs
Expand Up @@ -65,19 +65,23 @@ pub mod string;
pub mod vec;
pub mod vec_map;

#[stable]
pub mod bitv {
pub use bit::{Bitv, Iter};
}

#[stable]
pub mod bitv_set {
pub use bit::{BitvSet, Union, Intersection, Difference, SymmetricDifference};
pub use bit::SetIter as Iter;
}

#[stable]
pub mod btree_map {
pub use btree::map::*;
}

#[stable]
pub mod btree_set {
pub use btree::set::*;
}
Expand Down Expand Up @@ -109,8 +113,7 @@ mod prelude {
pub use core::iter::range;
pub use core::iter::{FromIterator, Extend, IteratorExt};
pub use core::iter::{Iterator, DoubleEndedIterator, RandomAccessIterator};
pub use core::iter::{IteratorCloneExt, CloneIteratorExt};
pub use core::iter::{IteratorOrdExt, MutableDoubleEndedIterator, ExactSizeIterator};
pub use core::iter::{ExactSizeIterator};
pub use core::kinds::{Copy, Send, Sized, Sync};
pub use core::mem::drop;
pub use core::ops::{Drop, Fn, FnMut, FnOnce};
Expand Down
2 changes: 2 additions & 0 deletions src/libcollections/ring_buf.rs
Expand Up @@ -12,6 +12,8 @@
//! ends of the container. It also has `O(1)` indexing like a vector. The contained elements are
//! not required to be copyable, and the queue will be sendable if the contained type is sendable.

#![stable]

use core::prelude::*;

use core::cmp::Ordering;
Expand Down
18 changes: 13 additions & 5 deletions src/libcollections/slice.rs
Expand Up @@ -86,6 +86,7 @@
//! * Further iterators exist that split, chunk or permute the slice.

#![doc(primitive = "slice")]
#![stable]

use alloc::boxed::Box;
use core::borrow::{BorrowFrom, BorrowFromMut, ToOwned};
Expand Down Expand Up @@ -121,8 +122,10 @@ pub type MutItems<'a, T:'a> = IterMut<'a, T>;
////////////////////////////////////////////////////////////////////////////////

/// Allocating extension methods for slices.
#[unstable = "needs associated types, may merge with other traits"]
pub trait SliceExt<T> for Sized? {
pub trait SliceExt for Sized? {
#[stable]
type Item;

/// Sorts the slice, in place, using `compare` to compare
/// elements.
///
Expand Down Expand Up @@ -561,8 +564,10 @@ pub trait SliceExt<T> for Sized? {
fn as_mut_ptr(&mut self) -> *mut T;
}

#[unstable = "trait is unstable"]
impl<T> SliceExt<T> for [T] {
#[stable]
impl<T> SliceExt for [T] {
type Item = T;

#[inline]
fn sort_by<F>(&mut self, compare: F) where F: FnMut(&T, &T) -> Ordering {
merge_sort(self, compare)
Expand Down Expand Up @@ -1113,7 +1118,10 @@ struct SizeDirection {
dir: Direction,
}

impl Iterator<(uint, uint)> for ElementSwaps {
#[stable]
impl Iterator for ElementSwaps {
type Item = (uint, uint);

#[inline]
fn next(&mut self) -> Option<(uint, uint)> {
fn new_pos(i: uint, s: Direction) -> uint {
Expand Down
6 changes: 6 additions & 0 deletions src/libcollections/str.rs
Expand Up @@ -165,13 +165,15 @@ enum DecompositionType {
/// External iterator for a string's decomposition's characters.
/// Use with the `std::iter` module.
#[derive(Clone)]
#[unstable]
pub struct Decompositions<'a> {
kind: DecompositionType,
iter: Chars<'a>,
buffer: Vec<(char, u8)>,
sorted: bool
}

#[stable]
impl<'a> Iterator for Decompositions<'a> {
type Item = char;

Expand Down Expand Up @@ -253,6 +255,7 @@ enum RecompositionState {
/// External iterator for a string's recomposition's characters.
/// Use with the `std::iter` module.
#[derive(Clone)]
#[unstable]
pub struct Recompositions<'a> {
iter: Decompositions<'a>,
state: RecompositionState,
Expand All @@ -261,6 +264,7 @@ pub struct Recompositions<'a> {
last_ccc: Option<u8>
}

#[stable]
impl<'a> Iterator for Recompositions<'a> {
type Item = char;

Expand Down Expand Up @@ -348,10 +352,12 @@ impl<'a> Iterator for Recompositions<'a> {
/// External iterator for a string's UTF16 codeunits.
/// Use with the `std::iter` module.
#[derive(Clone)]
#[unstable]
pub struct Utf16Units<'a> {
encoder: Utf16Encoder<Chars<'a>>
}

#[stable]
impl<'a> Iterator for Utf16Units<'a> {
type Item = u16;

Expand Down
8 changes: 4 additions & 4 deletions src/libcollections/string.rs
Expand Up @@ -687,7 +687,7 @@ impl fmt::Show for FromUtf16Error {
}
}

#[experimental = "waiting on FromIterator stabilization"]
#[stable]
impl FromIterator<char> for String {
fn from_iter<I:Iterator<Item=char>>(iterator: I) -> String {
let mut buf = String::new();
Expand All @@ -696,7 +696,7 @@ impl FromIterator<char> for String {
}
}

#[experimental = "waiting on FromIterator stabilization"]
#[stable]
impl<'a> FromIterator<&'a str> for String {
fn from_iter<I:Iterator<Item=&'a str>>(iterator: I) -> String {
let mut buf = String::new();
Expand Down Expand Up @@ -808,7 +808,7 @@ impl<H: hash::Writer> hash::Hash<H> for String {
}
}

#[experimental = "waiting on Add stabilization"]
#[unstable = "recent addition, needs more experience"]
impl<'a> Add<&'a str> for String {
type Output = String;

Expand Down Expand Up @@ -840,7 +840,7 @@ impl ops::Slice<uint, str> for String {
}
}

#[experimental = "waiting on Deref stabilization"]
#[stable]
impl ops::Deref for String {
type Target = str;

Expand Down
19 changes: 15 additions & 4 deletions src/libcollections/vec.rs
Expand Up @@ -1251,19 +1251,19 @@ impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
}
}

#[experimental = "waiting on Deref stability"]
#[stable]
impl<T> ops::Deref for Vec<T> {
type Target = [T];

fn deref<'a>(&'a self) -> &'a [T] { self.as_slice() }
}

#[experimental = "waiting on DerefMut stability"]
#[stable]
impl<T> ops::DerefMut for Vec<T> {
fn deref_mut<'a>(&'a mut self) -> &'a mut [T] { self.as_mut_slice() }
}

#[experimental = "waiting on FromIterator stability"]
#[stable]
impl<T> FromIterator<T> for Vec<T> {
#[inline]
fn from_iter<I:Iterator<Item=T>>(mut iterator: I) -> Vec<T> {
Expand Down Expand Up @@ -1393,6 +1393,7 @@ impl<T> AsSlice<T> for Vec<T> {
}
}

#[unstable = "recent addition, needs more experience"]
impl<'a, T: Clone> Add<&'a [T]> for Vec<T> {
type Output = Vec<T>;

Expand All @@ -1404,6 +1405,7 @@ impl<'a, T: Clone> Add<&'a [T]> for Vec<T> {
}

#[unsafe_destructor]
#[stable]
impl<T> Drop for Vec<T> {
fn drop(&mut self) {
// This is (and should always remain) a no-op if the fields are
Expand Down Expand Up @@ -1449,6 +1451,7 @@ impl<'a> fmt::Writer for Vec<u8> {
/// A clone-on-write vector
pub type CowVec<'a, T> = Cow<'a, Vec<T>, [T]>;

#[unstable]
impl<'a, T> FromIterator<T> for CowVec<'a, T> where T: Clone {
fn from_iter<I: Iterator<Item=T>>(it: I) -> CowVec<'a, T> {
Cow::Owned(FromIterator::from_iter(it))
Expand Down Expand Up @@ -1494,6 +1497,7 @@ impl<T> IntoIter<T> {
}
}

#[stable]
impl<T> Iterator for IntoIter<T> {
type Item = T;

Expand Down Expand Up @@ -1530,6 +1534,7 @@ impl<T> Iterator for IntoIter<T> {
}
}

#[stable]
impl<T> DoubleEndedIterator for IntoIter<T> {
#[inline]
fn next_back<'a>(&'a mut self) -> Option<T> {
Expand All @@ -1553,9 +1558,11 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
}
}

#[stable]
impl<T> ExactSizeIterator for IntoIter<T> {}

#[unsafe_destructor]
#[stable]
impl<T> Drop for IntoIter<T> {
fn drop(&mut self) {
// destroy the remaining elements
Expand All @@ -1577,6 +1584,7 @@ pub struct Drain<'a, T> {
marker: ContravariantLifetime<'a>,
}

#[stable]
impl<'a, T> Iterator for Drain<'a, T> {
type Item = T;

Expand Down Expand Up @@ -1613,6 +1621,7 @@ impl<'a, T> Iterator for Drain<'a, T> {
}
}

#[stable]
impl<'a, T> DoubleEndedIterator for Drain<'a, T> {
#[inline]
fn next_back(&mut self) -> Option<T> {
Expand All @@ -1636,9 +1645,11 @@ impl<'a, T> DoubleEndedIterator for Drain<'a, T> {
}
}

#[stable]
impl<'a, T> ExactSizeIterator for Drain<'a, T> {}

#[unsafe_destructor]
#[stable]
impl<'a, T> Drop for Drain<'a, T> {
fn drop(&mut self) {
// self.ptr == self.end == null if drop has already been called,
Expand Down Expand Up @@ -1671,7 +1682,7 @@ impl<'a, T> Deref for DerefVec<'a, T> {

// Prevent the inner `Vec<T>` from attempting to deallocate memory.
#[unsafe_destructor]
#[experimental]
#[stable]
impl<'a, T> Drop for DerefVec<'a, T> {
fn drop(&mut self) {
self.x.len = 0;
Expand Down

0 comments on commit 2e883a5

Please sign in to comment.