rollup merge of #20560: aturon/stab-2-iter-ops-slice
Conflicts: src/libcollections/slice.rs src/libcore/iter.rs src/libstd/sync/mpsc/mod.rs src/libstd/sync/rwlock.rs
This commit is contained in:
commit
2e883a5f53
@ -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;
|
||||
|
||||
@ -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>`.
|
||||
///
|
||||
@ -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>`.
|
||||
///
|
||||
|
@ -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 }
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
@ -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>`.
|
||||
///
|
||||
@ -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>`.
|
||||
///
|
||||
|
@ -148,6 +148,7 @@
|
||||
//! ```
|
||||
|
||||
#![allow(missing_docs)]
|
||||
#![stable]
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
@ -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() }
|
||||
@ -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>,
|
||||
}
|
||||
@ -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>,
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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::*;
|
||||
}
|
||||
@ -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};
|
||||
|
@ -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;
|
||||
|
@ -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};
|
||||
@ -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.
|
||||
///
|
||||
@ -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)
|
||||
@ -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 {
|
||||
|
@ -165,6 +165,7 @@ 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>,
|
||||
@ -172,6 +173,7 @@ pub struct Decompositions<'a> {
|
||||
sorted: bool
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a> Iterator for Decompositions<'a> {
|
||||
type Item = char;
|
||||
|
||||
@ -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,
|
||||
@ -261,6 +264,7 @@ pub struct Recompositions<'a> {
|
||||
last_ccc: Option<u8>
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a> Iterator for Recompositions<'a> {
|
||||
type Item = char;
|
||||
|
||||
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
@ -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();
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
|
@ -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> {
|
||||
@ -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>;
|
||||
|
||||
@ -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
|
||||
@ -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))
|
||||
@ -1494,6 +1497,7 @@ impl<T> IntoIter<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T> Iterator for IntoIter<T> {
|
||||
type Item = T;
|
||||
|
||||
@ -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> {
|
||||
@ -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
|
||||
@ -1577,6 +1584,7 @@ pub struct Drain<'a, T> {
|
||||
marker: ContravariantLifetime<'a>,
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, T> Iterator for Drain<'a, T> {
|
||||
type Item = T;
|
||||
|
||||
@ -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> {
|
||||
@ -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,
|
||||
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -419,7 +419,7 @@ pub struct Ref<'b, T:'b> {
|
||||
_borrow: BorrowRef<'b>,
|
||||
}
|
||||
|
||||
#[unstable = "waiting for `Deref` to become stable"]
|
||||
#[stable]
|
||||
impl<'b, T> Deref for Ref<'b, T> {
|
||||
type Target = T;
|
||||
|
||||
@ -477,7 +477,7 @@ pub struct RefMut<'b, T:'b> {
|
||||
_borrow: BorrowRefMut<'b>,
|
||||
}
|
||||
|
||||
#[unstable = "waiting for `Deref` to become stable"]
|
||||
#[stable]
|
||||
impl<'b, T> Deref for RefMut<'b, T> {
|
||||
type Target = T;
|
||||
|
||||
@ -487,7 +487,7 @@ impl<'b, T> Deref for RefMut<'b, T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable = "waiting for `DerefMut` to become stable"]
|
||||
#[stable]
|
||||
impl<'b, T> DerefMut for RefMut<'b, T> {
|
||||
#[inline]
|
||||
fn deref_mut<'a>(&'a mut self) -> &'a mut T {
|
||||
|
@ -314,6 +314,7 @@ pub struct EscapeUnicode {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[unstable]
|
||||
enum EscapeUnicodeState {
|
||||
Backslash,
|
||||
Type,
|
||||
@ -375,6 +376,7 @@ pub struct EscapeDefault {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[unstable]
|
||||
enum EscapeDefaultState {
|
||||
Backslash(char),
|
||||
Char(char),
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -59,6 +59,8 @@
|
||||
//! See the documentation for each trait for a minimum implementation that prints
|
||||
//! something to the screen.
|
||||
|
||||
#![stable]
|
||||
|
||||
use clone::Clone;
|
||||
use iter::{Step, Iterator,DoubleEndedIterator,ExactSizeIterator};
|
||||
use kinds::Sized;
|
||||
@ -86,8 +88,10 @@ use option::Option::{self, Some, None};
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="drop"]
|
||||
#[stable]
|
||||
pub trait Drop {
|
||||
/// The `drop` method, called when the value goes out of scope.
|
||||
#[stable]
|
||||
fn drop(&mut self);
|
||||
}
|
||||
|
||||
@ -120,15 +124,19 @@ pub trait Drop {
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="add"]
|
||||
#[stable]
|
||||
pub trait Add<RHS=Self> {
|
||||
#[stable]
|
||||
type Output;
|
||||
|
||||
/// The method for the `+` operator
|
||||
#[stable]
|
||||
fn add(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
macro_rules! add_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[stable]
|
||||
impl Add for $t {
|
||||
type Output = $t;
|
||||
|
||||
@ -169,15 +177,19 @@ add_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="sub"]
|
||||
#[stable]
|
||||
pub trait Sub<RHS=Self> {
|
||||
#[stable]
|
||||
type Output;
|
||||
|
||||
/// The method for the `-` operator
|
||||
#[stable]
|
||||
fn sub(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
macro_rules! sub_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[stable]
|
||||
impl Sub for $t {
|
||||
type Output = $t;
|
||||
|
||||
@ -218,15 +230,19 @@ sub_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="mul"]
|
||||
#[stable]
|
||||
pub trait Mul<RHS=Self> {
|
||||
#[stable]
|
||||
type Output;
|
||||
|
||||
/// The method for the `*` operator
|
||||
#[stable]
|
||||
fn mul(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
macro_rules! mul_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[stable]
|
||||
impl Mul for $t {
|
||||
type Output = $t;
|
||||
|
||||
@ -267,15 +283,19 @@ mul_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="div"]
|
||||
#[stable]
|
||||
pub trait Div<RHS=Self> {
|
||||
#[stable]
|
||||
type Output;
|
||||
|
||||
/// The method for the `/` operator
|
||||
#[stable]
|
||||
fn div(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
macro_rules! div_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[stable]
|
||||
impl Div for $t {
|
||||
type Output = $t;
|
||||
|
||||
@ -316,15 +336,19 @@ div_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="rem"]
|
||||
#[stable]
|
||||
pub trait Rem<RHS=Self> {
|
||||
#[stable]
|
||||
type Output = Self;
|
||||
|
||||
/// The method for the `%` operator
|
||||
#[stable]
|
||||
fn rem(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
macro_rules! rem_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[stable]
|
||||
impl Rem for $t {
|
||||
type Output = $t;
|
||||
|
||||
@ -336,6 +360,7 @@ macro_rules! rem_impl {
|
||||
|
||||
macro_rules! rem_float_impl {
|
||||
($t:ty, $fmod:ident) => {
|
||||
#[stable]
|
||||
impl Rem for $t {
|
||||
type Output = $t;
|
||||
|
||||
@ -382,19 +407,25 @@ rem_float_impl! { f64, fmod }
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="neg"]
|
||||
#[stable]
|
||||
pub trait Neg {
|
||||
#[stable]
|
||||
type Output;
|
||||
|
||||
/// The method for the unary `-` operator
|
||||
#[stable]
|
||||
fn neg(self) -> Self::Output;
|
||||
}
|
||||
|
||||
macro_rules! neg_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[stable]
|
||||
impl Neg for $t {
|
||||
#[stable]
|
||||
type Output = $t;
|
||||
|
||||
#[inline]
|
||||
#[stable]
|
||||
fn neg(self) -> $t { -self }
|
||||
}
|
||||
)*)
|
||||
@ -402,6 +433,7 @@ macro_rules! neg_impl {
|
||||
|
||||
macro_rules! neg_uint_impl {
|
||||
($t:ty, $t_signed:ty) => {
|
||||
#[stable]
|
||||
impl Neg for $t {
|
||||
type Output = $t;
|
||||
|
||||
@ -450,15 +482,19 @@ neg_uint_impl! { u64, i64 }
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="not"]
|
||||
#[stable]
|
||||
pub trait Not {
|
||||
#[stable]
|
||||
type Output;
|
||||
|
||||
/// The method for the unary `!` operator
|
||||
#[stable]
|
||||
fn not(self) -> Self::Output;
|
||||
}
|
||||
|
||||
macro_rules! not_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[stable]
|
||||
impl Not for $t {
|
||||
type Output = $t;
|
||||
|
||||
@ -499,15 +535,19 @@ not_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="bitand"]
|
||||
#[stable]
|
||||
pub trait BitAnd<RHS=Self> {
|
||||
#[stable]
|
||||
type Output;
|
||||
|
||||
/// The method for the `&` operator
|
||||
#[stable]
|
||||
fn bitand(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
macro_rules! bitand_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[stable]
|
||||
impl BitAnd for $t {
|
||||
type Output = $t;
|
||||
|
||||
@ -548,15 +588,19 @@ bitand_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="bitor"]
|
||||
#[stable]
|
||||
pub trait BitOr<RHS=Self> {
|
||||
#[stable]
|
||||
type Output;
|
||||
|
||||
/// The method for the `|` operator
|
||||
#[stable]
|
||||
fn bitor(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
macro_rules! bitor_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[stable]
|
||||
impl BitOr for $t {
|
||||
type Output = $t;
|
||||
|
||||
@ -597,15 +641,19 @@ bitor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="bitxor"]
|
||||
#[stable]
|
||||
pub trait BitXor<RHS=Self> {
|
||||
#[stable]
|
||||
type Output;
|
||||
|
||||
/// The method for the `^` operator
|
||||
#[stable]
|
||||
fn bitxor(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
macro_rules! bitxor_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[stable]
|
||||
impl BitXor for $t {
|
||||
type Output = $t;
|
||||
|
||||
@ -646,15 +694,19 @@ bitxor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="shl"]
|
||||
#[stable]
|
||||
pub trait Shl<RHS> {
|
||||
#[stable]
|
||||
type Output;
|
||||
|
||||
/// The method for the `<<` operator
|
||||
#[stable]
|
||||
fn shl(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
macro_rules! shl_impl {
|
||||
($($t:ty)*) => ($(
|
||||
#[stable]
|
||||
impl Shl<uint> for $t {
|
||||
type Output = $t;
|
||||
|
||||
@ -697,10 +749,13 @@ shl_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="shr"]
|
||||
#[stable]
|
||||
pub trait Shr<RHS> {
|
||||
#[stable]
|
||||
type Output;
|
||||
|
||||
/// The method for the `>>` operator
|
||||
#[stable]
|
||||
fn shr(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
@ -893,11 +948,13 @@ pub trait SliceMut<Sized? Idx, Sized? Result> for Sized? {
|
||||
/// An unbounded range.
|
||||
#[derive(Copy)]
|
||||
#[lang="full_range"]
|
||||
#[unstable = "API still in development"]
|
||||
pub struct FullRange;
|
||||
|
||||
/// A (half-open) range which is bounded at both ends.
|
||||
#[derive(Copy)]
|
||||
#[lang="range"]
|
||||
#[unstable = "API still in development"]
|
||||
pub struct Range<Idx> {
|
||||
/// The lower bound of the range (inclusive).
|
||||
pub start: Idx,
|
||||
@ -907,6 +964,7 @@ pub struct Range<Idx> {
|
||||
|
||||
// FIXME(#19391) needs a snapshot
|
||||
//impl<Idx: Clone + Step<T=uint>> Iterator<Idx> for Range<Idx> {
|
||||
#[unstable = "API still in development"]
|
||||
impl<Idx: Clone + Step> Iterator for Range<Idx> {
|
||||
type Item = Idx;
|
||||
|
||||
@ -931,6 +989,7 @@ impl<Idx: Clone + Step> Iterator for Range<Idx> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable = "API still in development"]
|
||||
impl<Idx: Clone + Step> DoubleEndedIterator for Range<Idx> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<Idx> {
|
||||
@ -943,16 +1002,19 @@ impl<Idx: Clone + Step> DoubleEndedIterator for Range<Idx> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable = "API still in development"]
|
||||
impl<Idx: Clone + Step> ExactSizeIterator for Range<Idx> {}
|
||||
|
||||
/// A range which is only bounded below.
|
||||
#[derive(Copy)]
|
||||
#[lang="range_from"]
|
||||
#[unstable = "API still in development"]
|
||||
pub struct RangeFrom<Idx> {
|
||||
/// The lower bound of the range (inclusive).
|
||||
pub start: Idx,
|
||||
}
|
||||
|
||||
#[unstable = "API still in development"]
|
||||
impl<Idx: Clone + Step> Iterator for RangeFrom<Idx> {
|
||||
type Item = Idx;
|
||||
|
||||
@ -968,6 +1030,7 @@ impl<Idx: Clone + Step> Iterator for RangeFrom<Idx> {
|
||||
/// A range which is only bounded above.
|
||||
#[derive(Copy)]
|
||||
#[lang="range_to"]
|
||||
#[unstable = "API still in development"]
|
||||
pub struct RangeTo<Idx> {
|
||||
/// The upper bound of the range (exclusive).
|
||||
pub end: Idx,
|
||||
@ -1005,19 +1068,24 @@ pub struct RangeTo<Idx> {
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="deref"]
|
||||
#[stable]
|
||||
pub trait Deref for Sized? {
|
||||
#[stable]
|
||||
type Sized? Target;
|
||||
|
||||
/// The method called to dereference a value
|
||||
#[stable]
|
||||
fn deref<'a>(&'a self) -> &'a Self::Target;
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, Sized? T> Deref for &'a T {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &T { *self }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, Sized? T> Deref for &'a mut T {
|
||||
type Target = T;
|
||||
|
||||
@ -1062,17 +1130,21 @@ impl<'a, Sized? T> Deref for &'a mut T {
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="deref_mut"]
|
||||
#[stable]
|
||||
pub trait DerefMut for Sized? : Deref {
|
||||
/// The method called to mutably dereference a value
|
||||
#[stable]
|
||||
fn deref_mut<'a>(&'a mut self) -> &'a mut <Self as Deref>::Target;
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, Sized? T> DerefMut for &'a mut T {
|
||||
fn deref_mut(&mut self) -> &mut T { *self }
|
||||
}
|
||||
|
||||
/// A version of the call operator that takes an immutable receiver.
|
||||
#[lang="fn"]
|
||||
#[unstable = "uncertain about variadic generics, input versus associated types"]
|
||||
pub trait Fn<Args,Result> for Sized? {
|
||||
/// This is called when the call operator is used.
|
||||
extern "rust-call" fn call(&self, args: Args) -> Result;
|
||||
@ -1080,6 +1152,7 @@ pub trait Fn<Args,Result> for Sized? {
|
||||
|
||||
/// A version of the call operator that takes a mutable receiver.
|
||||
#[lang="fn_mut"]
|
||||
#[unstable = "uncertain about variadic generics, input versus associated types"]
|
||||
pub trait FnMut<Args,Result> for Sized? {
|
||||
/// This is called when the call operator is used.
|
||||
extern "rust-call" fn call_mut(&mut self, args: Args) -> Result;
|
||||
@ -1087,6 +1160,7 @@ pub trait FnMut<Args,Result> for Sized? {
|
||||
|
||||
/// A version of the call operator that takes a by-value receiver.
|
||||
#[lang="fn_once"]
|
||||
#[unstable = "uncertain about variadic generics, input versus associated types"]
|
||||
pub trait FnOnce<Args,Result> {
|
||||
/// This is called when the call operator is used.
|
||||
extern "rust-call" fn call_once(self, args: Args) -> Result;
|
||||
|
@ -807,6 +807,7 @@ impl<A> ExactSizeIterator for Item<A> {}
|
||||
#[stable]
|
||||
pub struct Iter<'a, A: 'a> { inner: Item<&'a A> }
|
||||
|
||||
#[stable]
|
||||
impl<'a, A> Iterator for Iter<'a, A> {
|
||||
type Item = &'a A;
|
||||
|
||||
@ -816,11 +817,13 @@ impl<'a, A> Iterator for Iter<'a, A> {
|
||||
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, A> DoubleEndedIterator for Iter<'a, A> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a A> { self.inner.next_back() }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, A> ExactSizeIterator for Iter<'a, A> {}
|
||||
|
||||
#[stable]
|
||||
@ -834,6 +837,7 @@ impl<'a, A> Clone for Iter<'a, A> {
|
||||
#[stable]
|
||||
pub struct IterMut<'a, A: 'a> { inner: Item<&'a mut A> }
|
||||
|
||||
#[stable]
|
||||
impl<'a, A> Iterator for IterMut<'a, A> {
|
||||
type Item = &'a mut A;
|
||||
|
||||
@ -843,17 +847,20 @@ impl<'a, A> Iterator for IterMut<'a, A> {
|
||||
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, A> DoubleEndedIterator for IterMut<'a, A> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a mut A> { self.inner.next_back() }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, A> ExactSizeIterator for IterMut<'a, A> {}
|
||||
|
||||
/// An iterator over the item contained inside an Option.
|
||||
#[stable]
|
||||
pub struct IntoIter<A> { inner: Item<A> }
|
||||
|
||||
#[stable]
|
||||
impl<A> Iterator for IntoIter<A> {
|
||||
type Item = A;
|
||||
|
||||
@ -863,11 +870,13 @@ impl<A> Iterator for IntoIter<A> {
|
||||
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<A> DoubleEndedIterator for IntoIter<A> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<A> { self.inner.next_back() }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<A> ExactSizeIterator for IntoIter<A> {}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -43,8 +43,7 @@ pub use clone::Clone;
|
||||
pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
|
||||
pub use iter::{Extend, IteratorExt};
|
||||
pub use iter::{Iterator, DoubleEndedIterator};
|
||||
pub use iter::{IteratorCloneExt, CloneIteratorExt};
|
||||
pub use iter::{IteratorOrdExt, ExactSizeIterator};
|
||||
pub use iter::{ExactSizeIterator};
|
||||
pub use option::Option::{self, Some, None};
|
||||
pub use ptr::{PtrExt, MutPtrExt};
|
||||
pub use result::Result::{self, Ok, Err};
|
||||
|
@ -807,6 +807,7 @@ impl<T, E> AsSlice<T> for Result<T, E> {
|
||||
#[stable]
|
||||
pub struct Iter<'a, T: 'a> { inner: Option<&'a T> }
|
||||
|
||||
#[stable]
|
||||
impl<'a, T> Iterator for Iter<'a, T> {
|
||||
type Item = &'a T;
|
||||
|
||||
@ -819,11 +820,13 @@ impl<'a, T> Iterator for Iter<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a T> { self.inner.take() }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, T> ExactSizeIterator for Iter<'a, T> {}
|
||||
|
||||
impl<'a, T> Clone for Iter<'a, T> {
|
||||
@ -834,6 +837,7 @@ impl<'a, T> Clone for Iter<'a, T> {
|
||||
#[stable]
|
||||
pub struct IterMut<'a, T: 'a> { inner: Option<&'a mut T> }
|
||||
|
||||
#[stable]
|
||||
impl<'a, T> Iterator for IterMut<'a, T> {
|
||||
type Item = &'a mut T;
|
||||
|
||||
@ -846,17 +850,20 @@ impl<'a, T> Iterator for IterMut<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a mut T> { self.inner.take() }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, T> ExactSizeIterator for IterMut<'a, T> {}
|
||||
|
||||
/// An iterator over the value in a `Ok` variant of a `Result`.
|
||||
#[stable]
|
||||
pub struct IntoIter<T> { inner: Option<T> }
|
||||
|
||||
#[stable]
|
||||
impl<T> Iterator for IntoIter<T> {
|
||||
type Item = T;
|
||||
|
||||
@ -869,11 +876,13 @@ impl<T> Iterator for IntoIter<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T> DoubleEndedIterator for IntoIter<T> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<T> { self.inner.take() }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T> ExactSizeIterator for IntoIter<T> {}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -650,7 +650,7 @@ impl<'a, T> Default for &'a [T] {
|
||||
// The shared definition of the `Iter` and `IterMut` iterators
|
||||
macro_rules! iterator {
|
||||
(struct $name:ident -> $ptr:ty, $elem:ty) => {
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
impl<'a, T> Iterator for $name<'a, T> {
|
||||
type Item = $elem;
|
||||
|
||||
@ -688,7 +688,7 @@ macro_rules! iterator {
|
||||
}
|
||||
}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
impl<'a, T> DoubleEndedIterator for $name<'a, T> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<$elem> {
|
||||
@ -771,7 +771,7 @@ impl<'a,T> Copy for Iter<'a,T> {}
|
||||
|
||||
iterator!{struct Iter -> *const T, &'a T}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
impl<'a, T> ExactSizeIterator for Iter<'a, T> {}
|
||||
|
||||
#[stable]
|
||||
@ -779,7 +779,7 @@ impl<'a, T> Clone for Iter<'a, T> {
|
||||
fn clone(&self) -> Iter<'a, T> { *self }
|
||||
}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[experimental = "trait is experimental"]
|
||||
impl<'a, T> RandomAccessIterator for Iter<'a, T> {
|
||||
#[inline]
|
||||
fn indexable(&self) -> uint {
|
||||
@ -865,7 +865,7 @@ impl<'a, T> IterMut<'a, T> {
|
||||
|
||||
iterator!{struct IterMut -> *mut T, &'a mut T}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
impl<'a, T> ExactSizeIterator for IterMut<'a, T> {}
|
||||
|
||||
/// An internal abstraction over the splitting iterators, so that
|
||||
@ -897,7 +897,7 @@ impl<'a, T, P> Clone for Split<'a, T, P> where P: Clone + FnMut(&T) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
impl<'a, T, P> Iterator for Split<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
type Item = &'a [T];
|
||||
|
||||
@ -925,7 +925,7 @@ impl<'a, T, P> Iterator for Split<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
impl<'a, T, P> DoubleEndedIterator for Split<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a [T]> {
|
||||
@ -970,7 +970,7 @@ impl<'a, T, P> SplitIter for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
impl<'a, T, P> Iterator for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
type Item = &'a mut [T];
|
||||
|
||||
@ -1005,7 +1005,7 @@ impl<'a, T, P> Iterator for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
impl<'a, T, P> DoubleEndedIterator for SplitMut<'a, T, P> where
|
||||
P: FnMut(&T) -> bool,
|
||||
{
|
||||
@ -1038,7 +1038,6 @@ struct GenericSplitN<I> {
|
||||
invert: bool
|
||||
}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
impl<T, I: SplitIter + Iterator<Item=T>> Iterator for GenericSplitN<I> {
|
||||
type Item = T;
|
||||
|
||||
@ -1061,6 +1060,7 @@ impl<T, I: SplitIter + Iterator<Item=T>> Iterator for GenericSplitN<I> {
|
||||
|
||||
/// An iterator over subslices separated by elements that match a predicate
|
||||
/// function, limited to a given number of splits.
|
||||
#[stable]
|
||||
pub struct SplitN<'a, T: 'a, P> where P: FnMut(&T) -> bool {
|
||||
inner: GenericSplitN<Split<'a, T, P>>
|
||||
}
|
||||
@ -1068,12 +1068,14 @@ pub struct SplitN<'a, T: 'a, P> where P: FnMut(&T) -> bool {
|
||||
/// An iterator over subslices separated by elements that match a
|
||||
/// predicate function, limited to a given number of splits, starting
|
||||
/// from the end of the slice.
|
||||
#[stable]
|
||||
pub struct RSplitN<'a, T: 'a, P> where P: FnMut(&T) -> bool {
|
||||
inner: GenericSplitN<Split<'a, T, P>>
|
||||
}
|
||||
|
||||
/// An iterator over subslices separated by elements that match a predicate
|
||||
/// function, limited to a given number of splits.
|
||||
#[stable]
|
||||
pub struct SplitNMut<'a, T: 'a, P> where P: FnMut(&T) -> bool {
|
||||
inner: GenericSplitN<SplitMut<'a, T, P>>
|
||||
}
|
||||
@ -1081,12 +1083,14 @@ pub struct SplitNMut<'a, T: 'a, P> where P: FnMut(&T) -> bool {
|
||||
/// An iterator over subslices separated by elements that match a
|
||||
/// predicate function, limited to a given number of splits, starting
|
||||
/// from the end of the slice.
|
||||
#[stable]
|
||||
pub struct RSplitNMut<'a, T: 'a, P> where P: FnMut(&T) -> bool {
|
||||
inner: GenericSplitN<SplitMut<'a, T, P>>
|
||||
}
|
||||
|
||||
macro_rules! forward_iterator {
|
||||
($name:ident: $elem:ident, $iter_of:ty) => {
|
||||
#[stable]
|
||||
impl<'a, $elem, P> Iterator for $name<'a, $elem, P> where
|
||||
P: FnMut(&T) -> bool
|
||||
{
|
||||
@ -1112,12 +1116,13 @@ forward_iterator! { RSplitNMut: T, &'a mut [T] }
|
||||
|
||||
/// An iterator over overlapping subslices of length `size`.
|
||||
#[derive(Clone)]
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
pub struct Windows<'a, T:'a> {
|
||||
v: &'a [T],
|
||||
size: uint
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, T> Iterator for Windows<'a, T> {
|
||||
type Item = &'a [T];
|
||||
|
||||
@ -1149,13 +1154,13 @@ impl<'a, T> Iterator for Windows<'a, T> {
|
||||
/// When the slice len is not evenly divided by the chunk size, the last slice
|
||||
/// of the iteration will be the remainder.
|
||||
#[derive(Clone)]
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
pub struct Chunks<'a, T:'a> {
|
||||
v: &'a [T],
|
||||
size: uint
|
||||
}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
impl<'a, T> Iterator for Chunks<'a, T> {
|
||||
type Item = &'a [T];
|
||||
|
||||
@ -1184,7 +1189,7 @@ impl<'a, T> Iterator for Chunks<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
impl<'a, T> DoubleEndedIterator for Chunks<'a, T> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a [T]> {
|
||||
@ -1200,7 +1205,7 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[experimental = "trait is experimental"]
|
||||
impl<'a, T> RandomAccessIterator for Chunks<'a, T> {
|
||||
#[inline]
|
||||
fn indexable(&self) -> uint {
|
||||
@ -1224,13 +1229,13 @@ impl<'a, T> RandomAccessIterator for Chunks<'a, T> {
|
||||
/// An iterator over a slice in (non-overlapping) mutable chunks (`size`
|
||||
/// elements at a time). When the slice len is not evenly divided by the chunk
|
||||
/// size, the last slice of the iteration will be the remainder.
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
pub struct ChunksMut<'a, T:'a> {
|
||||
v: &'a mut [T],
|
||||
chunk_size: uint
|
||||
}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
impl<'a, T> Iterator for ChunksMut<'a, T> {
|
||||
type Item = &'a mut [T];
|
||||
|
||||
@ -1260,7 +1265,7 @@ impl<'a, T> Iterator for ChunksMut<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[experimental = "needs review"]
|
||||
#[stable]
|
||||
impl<'a, T> DoubleEndedIterator for ChunksMut<'a, T> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a mut [T]> {
|
||||
@ -1338,7 +1343,7 @@ pub unsafe fn from_raw_buf<'a, T>(p: &'a *const T, len: uint) -> &'a [T] {
|
||||
/// not being able to provide a non-aliasing guarantee of the returned mutable
|
||||
/// slice.
|
||||
#[inline]
|
||||
#[unstable = "jshould be renamed to from_raw_parts_mut"]
|
||||
#[unstable = "should be renamed to from_raw_parts_mut"]
|
||||
pub unsafe fn from_raw_mut_buf<'a, T>(p: &'a *mut T, len: uint) -> &'a mut [T] {
|
||||
transmute(RawSlice { data: *p as *const T, len: len })
|
||||
}
|
||||
|
@ -37,11 +37,8 @@ use uint;
|
||||
macro_rules! delegate_iter {
|
||||
(exact $te:ty in $ti:ty) => {
|
||||
delegate_iter!{$te in $ti}
|
||||
#[stable]
|
||||
impl<'a> ExactSizeIterator for $ti {
|
||||
#[inline]
|
||||
fn rposition<P>(&mut self, predicate: P) -> Option<uint> where P: FnMut($te) -> bool{
|
||||
self.0.rposition(predicate)
|
||||
}
|
||||
#[inline]
|
||||
fn len(&self) -> uint {
|
||||
self.0.len()
|
||||
@ -49,6 +46,7 @@ macro_rules! delegate_iter {
|
||||
}
|
||||
};
|
||||
($te:ty in $ti:ty) => {
|
||||
#[stable]
|
||||
impl<'a> Iterator for $ti {
|
||||
type Item = $te;
|
||||
|
||||
@ -61,6 +59,7 @@ macro_rules! delegate_iter {
|
||||
self.0.size_hint()
|
||||
}
|
||||
}
|
||||
#[stable]
|
||||
impl<'a> DoubleEndedIterator for $ti {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<$te> {
|
||||
@ -69,6 +68,7 @@ macro_rules! delegate_iter {
|
||||
}
|
||||
};
|
||||
(pattern $te:ty in $ti:ty) => {
|
||||
#[stable]
|
||||
impl<'a, P: CharEq> Iterator for $ti {
|
||||
type Item = $te;
|
||||
|
||||
@ -81,6 +81,7 @@ macro_rules! delegate_iter {
|
||||
self.0.size_hint()
|
||||
}
|
||||
}
|
||||
#[stable]
|
||||
impl<'a, P: CharEq> DoubleEndedIterator for $ti {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<$te> {
|
||||
@ -89,6 +90,7 @@ macro_rules! delegate_iter {
|
||||
}
|
||||
};
|
||||
(pattern forward $te:ty in $ti:ty) => {
|
||||
#[stable]
|
||||
impl<'a, P: CharEq> Iterator for $ti {
|
||||
type Item = $te;
|
||||
|
||||
@ -275,6 +277,7 @@ fn unwrap_or_0(opt: Option<&u8>) -> u8 {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a> Iterator for Chars<'a> {
|
||||
type Item = char;
|
||||
|
||||
@ -320,6 +323,7 @@ impl<'a> Iterator for Chars<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a> DoubleEndedIterator for Chars<'a> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<char> {
|
||||
@ -356,11 +360,13 @@ impl<'a> DoubleEndedIterator for Chars<'a> {
|
||||
/// External iterator for a string's characters and their byte offsets.
|
||||
/// Use with the `std::iter` module.
|
||||
#[derive(Clone)]
|
||||
#[stable]
|
||||
pub struct CharIndices<'a> {
|
||||
front_offset: uint,
|
||||
iter: Chars<'a>,
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a> Iterator for CharIndices<'a> {
|
||||
type Item = (uint, char);
|
||||
|
||||
@ -384,6 +390,7 @@ impl<'a> Iterator for CharIndices<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a> DoubleEndedIterator for CharIndices<'a> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<(uint, char)> {
|
||||
@ -465,6 +472,7 @@ impl<'a, Sep> CharSplits<'a, Sep> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, Sep: CharEq> Iterator for CharSplits<'a, Sep> {
|
||||
type Item = &'a str;
|
||||
|
||||
@ -499,6 +507,7 @@ impl<'a, Sep: CharEq> Iterator for CharSplits<'a, Sep> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, Sep: CharEq> DoubleEndedIterator for CharSplits<'a, Sep> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a str> {
|
||||
@ -540,6 +549,7 @@ impl<'a, Sep: CharEq> DoubleEndedIterator for CharSplits<'a, Sep> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a, Sep: CharEq> Iterator for CharSplitsN<'a, Sep> {
|
||||
type Item = &'a str;
|
||||
|
||||
@ -865,6 +875,7 @@ pub struct SplitStr<'a> {
|
||||
finished: bool
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a> Iterator for MatchIndices<'a> {
|
||||
type Item = (uint, uint);
|
||||
|
||||
@ -881,6 +892,7 @@ impl<'a> Iterator for MatchIndices<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a> Iterator for SplitStr<'a> {
|
||||
type Item = &'a str;
|
||||
|
||||
@ -1586,6 +1598,7 @@ impl<'a> Default for &'a str {
|
||||
fn default() -> &'a str { "" }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a> Iterator for Lines<'a> {
|
||||
type Item = &'a str;
|
||||
|
||||
@ -1593,11 +1606,13 @@ impl<'a> Iterator for Lines<'a> {
|
||||
fn next(&mut self) -> Option<&'a str> { self.inner.next() }
|
||||
#[inline]
|
||||
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
|
||||
}
|
||||
|
||||
#[stable]}
|
||||
impl<'a> DoubleEndedIterator for Lines<'a> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a str> { self.inner.next_back() }
|
||||
}
|
||||
|
||||
#[stable]}
|
||||
impl<'a> Iterator for LinesAny<'a> {
|
||||
type Item = &'a str;
|
||||
|
||||
@ -1605,7 +1620,8 @@ impl<'a> Iterator for LinesAny<'a> {
|
||||
fn next(&mut self) -> Option<&'a str> { self.inner.next() }
|
||||
#[inline]
|
||||
fn size_hint(&self) -> (uint, Option<uint>) { self.inner.size_hint() }
|
||||
}
|
||||
|
||||
#[stable]}
|
||||
impl<'a> DoubleEndedIterator for LinesAny<'a> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a str> { self.inner.next_back() }
|
||||
|
@ -18,7 +18,7 @@ use default::Default;
|
||||
use fmt::Show;
|
||||
use fmt;
|
||||
use hash::{Hash, Hasher, RandomSipHasher};
|
||||
use iter::{Iterator, IteratorExt, IteratorCloneExt, FromIterator, Map, Chain, Extend};
|
||||
use iter::{Iterator, IteratorExt, FromIterator, Map, Chain, Extend};
|
||||
use ops::{BitOr, BitAnd, BitXor, Sub};
|
||||
use option::Option::{Some, None, self};
|
||||
use result::Result::{Ok, Err};
|
||||
|
@ -309,7 +309,7 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
#![experimental]
|
||||
#![stable]
|
||||
|
||||
pub use core_collections::{BinaryHeap, Bitv, BitvSet, BTreeMap, BTreeSet};
|
||||
pub use core_collections::{DList, RingBuf, VecMap};
|
||||
@ -322,11 +322,13 @@ pub use self::hash_set::HashSet;
|
||||
|
||||
mod hash;
|
||||
|
||||
#[stable]
|
||||
pub mod hash_map {
|
||||
//! A hashmap
|
||||
pub use super::hash::map::*;
|
||||
}
|
||||
|
||||
#[stable]
|
||||
pub mod hash_set {
|
||||
//! A hashset
|
||||
pub use super::hash::set::*;
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
use cmp;
|
||||
use io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult};
|
||||
use iter::ExactSizeIterator;
|
||||
use iter::{IteratorExt, ExactSizeIterator};
|
||||
use ops::Drop;
|
||||
use option::Option;
|
||||
use option::Option::{Some, None};
|
||||
|
@ -25,11 +25,9 @@
|
||||
#[stable] #[doc(no_inline)] pub use char::CharExt;
|
||||
#[stable] #[doc(no_inline)] pub use clone::Clone;
|
||||
#[stable] #[doc(no_inline)] pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
|
||||
#[stable] #[doc(no_inline)] pub use iter::CloneIteratorExt;
|
||||
#[stable] #[doc(no_inline)] pub use iter::DoubleEndedIterator;
|
||||
#[stable] #[doc(no_inline)] pub use iter::ExactSizeIterator;
|
||||
#[stable] #[doc(no_inline)] pub use iter::{Iterator, IteratorExt, Extend};
|
||||
#[stable] #[doc(no_inline)] pub use iter::{IteratorCloneExt, IteratorOrdExt};
|
||||
#[stable] #[doc(no_inline)] pub use option::Option::{self, Some, None};
|
||||
#[stable] #[doc(no_inline)] pub use ptr::{PtrExt, MutPtrExt};
|
||||
#[stable] #[doc(no_inline)] pub use result::Result::{self, Ok, Err};
|
||||
|
@ -188,6 +188,7 @@ impl Condvar {
|
||||
pub fn notify_all(&self) { unsafe { self.inner.inner.notify_all() } }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl Drop for Condvar {
|
||||
fn drop(&mut self) {
|
||||
unsafe { self.inner.inner.destroy() }
|
||||
|
@ -675,6 +675,7 @@ impl<T: Send> Clone for Sender<T> {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[stable]
|
||||
impl<T: Send> Drop for Sender<T> {
|
||||
fn drop(&mut self) {
|
||||
match *unsafe { self.inner_mut() } {
|
||||
@ -768,6 +769,7 @@ impl<T: Send> Clone for SyncSender<T> {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[stable]
|
||||
impl<T: Send> Drop for SyncSender<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe { (*self.inner.get()).drop_chan(); }
|
||||
@ -1006,12 +1008,15 @@ impl<T: Send> select::Packet for Receiver<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable]
|
||||
impl<'a, T: Send> Iterator<T> for Messages<'a, T> {
|
||||
fn next(&mut self) -> Option<T> { self.rx.recv_opt().ok() }
|
||||
#[stable]
|
||||
impl<'a, T: Send> Iterator for Iter<'a, T> {
|
||||
type Item = T;
|
||||
|
||||
fn next(&mut self) -> Option<T> { self.rx.recv().ok() }
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[stable]
|
||||
impl<T: Send> Drop for Receiver<T> {
|
||||
fn drop(&mut self) {
|
||||
match *unsafe { self.inner_mut() } {
|
||||
|
@ -138,6 +138,7 @@ impl<T: Send> Queue<T> {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[stable]
|
||||
impl<T: Send> Drop for Queue<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
|
@ -228,6 +228,7 @@ impl<T: Send> Mutex<T> {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[stable]
|
||||
impl<T: Send> Drop for Mutex<T> {
|
||||
fn drop(&mut self) {
|
||||
// This is actually safe b/c we know that there is no further usage of
|
||||
@ -291,6 +292,7 @@ impl<'mutex, T> MutexGuard<'mutex, T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'mutex, T> Deref for MutexGuard<'mutex, T> {
|
||||
type Target = T;
|
||||
|
||||
@ -298,6 +300,7 @@ impl<'mutex, T> Deref for MutexGuard<'mutex, T> {
|
||||
unsafe { &*self.__data.get() }
|
||||
}
|
||||
}
|
||||
#[stable]
|
||||
impl<'mutex, T> DerefMut for MutexGuard<'mutex, T> {
|
||||
fn deref_mut<'a>(&'a mut self) -> &'a mut T {
|
||||
unsafe { &mut *self.__data.get() }
|
||||
@ -305,6 +308,7 @@ impl<'mutex, T> DerefMut for MutexGuard<'mutex, T> {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[stable]
|
||||
impl<'a, T> Drop for MutexGuard<'a, T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
|
@ -228,6 +228,7 @@ impl<T: Send + Sync> RwLock<T> {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[stable]
|
||||
impl<T> Drop for RwLock<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe { self.inner.lock.destroy() }
|
||||
@ -327,16 +328,19 @@ impl<'rwlock, T> RwLockWriteGuard<'rwlock, T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'rwlock, T> Deref for RwLockReadGuard<'rwlock, T> {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &T { unsafe { &*self.__data.get() } }
|
||||
}
|
||||
#[stable]
|
||||
impl<'rwlock, T> Deref for RwLockWriteGuard<'rwlock, T> {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &T { unsafe { &*self.__data.get() } }
|
||||
}
|
||||
#[stable]
|
||||
impl<'rwlock, T> DerefMut for RwLockWriteGuard<'rwlock, T> {
|
||||
fn deref_mut(&mut self) -> &mut T {
|
||||
unsafe { &mut *self.__data.get() }
|
||||
@ -344,6 +348,7 @@ impl<'rwlock, T> DerefMut for RwLockWriteGuard<'rwlock, T> {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[stable]
|
||||
impl<'a, T> Drop for RwLockReadGuard<'a, T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe { self.__lock.lock.read_unlock(); }
|
||||
@ -351,6 +356,7 @@ impl<'a, T> Drop for RwLockReadGuard<'a, T> {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[stable]
|
||||
impl<'a, T> Drop for RwLockWriteGuard<'a, T> {
|
||||
fn drop(&mut self) {
|
||||
self.__lock.poison.done(&self.__poison);
|
||||
|
@ -99,6 +99,7 @@ impl Semaphore {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[stable]
|
||||
impl<'a> Drop for SemaphoreGuard<'a> {
|
||||
fn drop(&mut self) {
|
||||
self.sem.release();
|
||||
|
@ -423,6 +423,7 @@ impl<T: Send> JoinGuard<T> {
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
#[stable]
|
||||
impl<T: Send> Drop for JoinGuard<T> {
|
||||
fn drop(&mut self) {
|
||||
if !self.joined {
|
||||
|
Loading…
x
Reference in New Issue
Block a user