Skip to content

Final pre-alpha stabilization of: iter, ops, slice, collections #20560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any notes on this call?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't read anything into the #[stable] here other than: if we have Weak, we'll keep the Drop impl.

impl<T: Sync + Send> Drop for Weak<T> {
/// Drops the `Weak<T>`.
///
Expand Down
2 changes: 2 additions & 0 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
7 changes: 5 additions & 2 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
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 @@ -119,8 +120,9 @@ pub use core::slice::{from_raw_buf, from_raw_mut_buf};
////////////////////////////////////////////////////////////////////////////////

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

/// Sorts the slice, in place, using `compare` to compare
Expand Down Expand Up @@ -699,7 +701,7 @@ pub trait SliceExt for Sized? {
fn into_vec(self: Box<Self>) -> Vec<Self::Item>;
}

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

Expand Down Expand Up @@ -1090,6 +1092,7 @@ struct SizeDirection {
dir: Direction,
}

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

Expand Down
6 changes: 6 additions & 0 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,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 @@ -720,7 +720,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 @@ -832,7 +832,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 @@ -864,7 +864,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
Original file line number Diff line number Diff line change
Expand Up @@ -1272,19 +1272,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 @@ -1414,6 +1414,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 @@ -1425,6 +1426,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 @@ -1470,6 +1472,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 @@ -1515,6 +1518,7 @@ impl<T> IntoIter<T> {
}
}

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

Expand Down Expand Up @@ -1551,6 +1555,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 @@ -1574,9 +1579,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 @@ -1598,6 +1605,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 @@ -1634,6 +1642,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 @@ -1657,9 +1666,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 @@ -1692,7 +1703,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
1 change: 1 addition & 0 deletions src/libcore/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ impl<'a, T, Sized? B> Cow<'a, T, B> where B: ToOwned<T> {
}
}

#[stable]
impl<'a, T, Sized? B> Deref for Cow<'a, T, B> where B: ToOwned<T> {
type Target = B;

Expand Down
Loading