collections: Split the `collections` feature

This commit also deprecates the `as_string` and `as_slice` free functions in the
`string` and `vec` modules.
This commit is contained in:
Alex Crichton 2015-06-09 14:39:23 -07:00
parent c44f5399e4
commit d444d0c357
30 changed files with 197 additions and 155 deletions

View File

@ -10,10 +10,11 @@
//! A priority queue implemented with a binary heap. //! A priority queue implemented with a binary heap.
//! //!
//! Insertion and popping the largest element have `O(log n)` time complexity. Checking the largest //! Insertion and popping the largest element have `O(log n)` time complexity.
//! element is `O(1)`. Converting a vector to a binary heap can be done in-place, and has `O(n)` //! Checking the largest element is `O(1)`. Converting a vector to a binary heap
//! complexity. A binary heap can also be converted to a sorted vector in-place, allowing it to //! can be done in-place, and has `O(n)` complexity. A binary heap can also be
//! be used for an `O(n log n)` in-place heapsort. //! converted to a sorted vector in-place, allowing it to be used for an `O(n
//! log n)` in-place heapsort.
//! //!
//! # Examples //! # Examples
//! //!
@ -539,8 +540,9 @@ impl<T: Ord> BinaryHeap<T> {
/// ///
/// The elements are removed in arbitrary order. /// The elements are removed in arbitrary order.
#[inline] #[inline]
#[unstable(feature = "collections", #[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle")] reason = "matches collection reform specification, \
waiting for dust to settle")]
pub fn drain(&mut self) -> Drain<T> { pub fn drain(&mut self) -> Drain<T> {
Drain { iter: self.data.drain(..) } Drain { iter: self.data.drain(..) }
} }
@ -678,7 +680,7 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
impl<T> ExactSizeIterator for IntoIter<T> {} impl<T> ExactSizeIterator for IntoIter<T> {}
/// An iterator that drains a `BinaryHeap`. /// An iterator that drains a `BinaryHeap`.
#[unstable(feature = "collections", reason = "recent addition")] #[unstable(feature = "drain", reason = "recent addition")]
pub struct Drain<'a, T: 'a> { pub struct Drain<'a, T: 'a> {
iter: vec::Drain<'a, T>, iter: vec::Drain<'a, T>,
} }

View File

@ -156,8 +156,7 @@ const FALSE: &'static bool = &false;
/// println!("{:?}", bv); /// println!("{:?}", bv);
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count()); /// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "bitvec", reason = "RFC 509")]
reason = "RFC 509")]
pub struct BitVec { pub struct BitVec {
/// Internal representation of the bit vector /// Internal representation of the bit vector
storage: Vec<u32>, storage: Vec<u32>,
@ -181,14 +180,16 @@ impl Index<usize> for BitVec {
/// Computes how many blocks are needed to store that many bits /// Computes how many blocks are needed to store that many bits
fn blocks_for_bits(bits: usize) -> usize { fn blocks_for_bits(bits: usize) -> usize {
// If we want 17 bits, dividing by 32 will produce 0. So we add 1 to make sure we // If we want 17 bits, dividing by 32 will produce 0. So we add 1 to make
// reserve enough. But if we want exactly a multiple of 32, this will actually allocate // sure we reserve enough. But if we want exactly a multiple of 32, this
// one too many. So we need to check if that's the case. We can do that by computing if // will actually allocate one too many. So we need to check if that's the
// bitwise AND by `32 - 1` is 0. But LLVM should be able to optimize the semantically // case. We can do that by computing if bitwise AND by `32 - 1` is 0. But
// superior modulo operator on a power of two to this. // LLVM should be able to optimize the semantically superior modulo operator
// on a power of two to this.
// //
// Note that we can technically avoid this branch with the expression // Note that we can technically avoid this branch with the expression
// `(nbits + u32::BITS - 1) / 32::BITS`, but if nbits is almost usize::MAX this will overflow. // `(nbits + u32::BITS - 1) / 32::BITS`, but if nbits is almost usize::MAX
// this will overflow.
if bits % u32::BITS == 0 { if bits % u32::BITS == 0 {
bits / u32::BITS bits / u32::BITS
} else { } else {
@ -202,6 +203,7 @@ fn mask_for_bits(bits: usize) -> u32 {
!0 >> (u32::BITS - bits % u32::BITS) % u32::BITS !0 >> (u32::BITS - bits % u32::BITS) % u32::BITS
} }
#[unstable(feature = "bitvec", reason = "RFC 509")]
impl BitVec { impl BitVec {
/// Applies the given operation to the blocks of self and other, and sets /// Applies the given operation to the blocks of self and other, and sets
/// self to be the result. This relies on the caller not to corrupt the /// self to be the result. This relies on the caller not to corrupt the
@ -407,8 +409,6 @@ impl BitVec {
/// assert_eq!(bv[3], true); /// assert_eq!(bv[3], true);
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "collections",
reason = "panic semantics are likely to change in the future")]
pub fn set(&mut self, i: usize, x: bool) { pub fn set(&mut self, i: usize, x: bool) {
assert!(i < self.nbits); assert!(i < self.nbits);
let w = i / u32::BITS; let w = i / u32::BITS;
@ -608,7 +608,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections, bit_vec_append_split_off)] /// # #![feature(bitvec, append)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut a = BitVec::from_bytes(&[0b10000000]); /// let mut a = BitVec::from_bytes(&[0b10000000]);
@ -621,7 +621,7 @@ impl BitVec {
/// assert!(a.eq_vec(&[true, false, false, false, false, false, false, false, /// assert!(a.eq_vec(&[true, false, false, false, false, false, false, false,
/// false, true, true, false, false, false, false, true])); /// false, true, true, false, false, false, false, true]));
/// ``` /// ```
#[unstable(feature = "bit_vec_append_split_off", #[unstable(feature = "append",
reason = "recently added as part of collections reform 2")] reason = "recently added as part of collections reform 2")]
pub fn append(&mut self, other: &mut Self) { pub fn append(&mut self, other: &mut Self) {
let b = self.len() % u32::BITS; let b = self.len() % u32::BITS;
@ -651,7 +651,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections, bit_vec_append_split_off)] /// # #![feature(bitvec, split_off)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// let mut a = BitVec::new(); /// let mut a = BitVec::new();
/// a.push(true); /// a.push(true);
@ -666,7 +666,7 @@ impl BitVec {
/// assert!(a.eq_vec(&[true, false])); /// assert!(a.eq_vec(&[true, false]));
/// assert!(b.eq_vec(&[false, true])); /// assert!(b.eq_vec(&[false, true]));
/// ``` /// ```
#[unstable(feature = "bit_vec_append_split_off", #[unstable(feature = "split_off",
reason = "recently added as part of collections reform 2")] reason = "recently added as part of collections reform 2")]
pub fn split_off(&mut self, at: usize) -> Self { pub fn split_off(&mut self, at: usize) -> Self {
assert!(at <= self.len(), "`at` out of bounds"); assert!(at <= self.len(), "`at` out of bounds");
@ -1254,8 +1254,7 @@ impl<'a> IntoIterator for &'a BitVec {
/// assert!(bv[3]); /// assert!(bv[3]);
/// ``` /// ```
#[derive(Clone)] #[derive(Clone)]
#[unstable(feature = "collections", #[unstable(feature = "bitset", reason = "RFC 509")]
reason = "RFC 509")]
pub struct BitSet { pub struct BitSet {
bit_vec: BitVec, bit_vec: BitVec,
} }
@ -1322,6 +1321,7 @@ impl cmp::PartialEq for BitSet {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl cmp::Eq for BitSet {} impl cmp::Eq for BitSet {}
#[unstable(feature = "bitset", reason = "RFC 509")]
impl BitSet { impl BitSet {
/// Creates a new empty `BitSet`. /// Creates a new empty `BitSet`.
/// ///
@ -1808,7 +1808,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections, bit_set_append_split_off)] /// # #![feature(collections, append)]
/// use std::collections::{BitVec, BitSet}; /// use std::collections::{BitVec, BitSet};
/// ///
/// let mut a = BitSet::new(); /// let mut a = BitSet::new();
@ -1826,7 +1826,7 @@ impl BitSet {
/// assert_eq!(b.len(), 0); /// assert_eq!(b.len(), 0);
/// assert_eq!(a, BitSet::from_bit_vec(BitVec::from_bytes(&[0b01110010]))); /// assert_eq!(a, BitSet::from_bit_vec(BitVec::from_bytes(&[0b01110010])));
/// ``` /// ```
#[unstable(feature = "bit_set_append_split_off", #[unstable(feature = "append",
reason = "recently added as part of collections reform 2")] reason = "recently added as part of collections reform 2")]
pub fn append(&mut self, other: &mut Self) { pub fn append(&mut self, other: &mut Self) {
self.union_with(other); self.union_with(other);
@ -1839,7 +1839,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections, bit_set_append_split_off)] /// # #![feature(bitset, split_off)]
/// use std::collections::{BitSet, BitVec}; /// use std::collections::{BitSet, BitVec};
/// let mut a = BitSet::new(); /// let mut a = BitSet::new();
/// a.insert(2); /// a.insert(2);
@ -1854,7 +1854,7 @@ impl BitSet {
/// assert_eq!(a, BitSet::from_bit_vec(BitVec::from_bytes(&[0b01100000]))); /// assert_eq!(a, BitSet::from_bit_vec(BitVec::from_bytes(&[0b01100000])));
/// assert_eq!(b, BitSet::from_bit_vec(BitVec::from_bytes(&[0b00010010]))); /// assert_eq!(b, BitSet::from_bit_vec(BitVec::from_bytes(&[0b00010010])));
/// ``` /// ```
#[unstable(feature = "bit_set_append_split_off", #[unstable(feature = "split_off",
reason = "recently added as part of collections reform 2")] reason = "recently added as part of collections reform 2")]
pub fn split_off(&mut self, at: usize) -> Self { pub fn split_off(&mut self, at: usize) -> Self {
let mut other = BitSet::new(); let mut other = BitSet::new();

View File

@ -1520,7 +1520,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// } /// }
/// assert_eq!(Some((&5, &"b")), map.range(Included(&4), Unbounded).next()); /// assert_eq!(Some((&5, &"b")), map.range(Included(&4), Unbounded).next());
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "btree_range",
reason = "matches collection reform specification, waiting for dust to settle")] reason = "matches collection reform specification, waiting for dust to settle")]
pub fn range<'a>(&'a self, min: Bound<&K>, max: Bound<&K>) -> Range<'a, K, V> { pub fn range<'a>(&'a self, min: Bound<&K>, max: Bound<&K>) -> Range<'a, K, V> {
range_impl!(&self.root, min, max, as_slices_internal, iter, Range, edges, []) range_impl!(&self.root, min, max, as_slices_internal, iter, Range, edges, [])
@ -1548,7 +1548,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// println!("{} => {}", name, balance); /// println!("{} => {}", name, balance);
/// } /// }
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "btree_range",
reason = "matches collection reform specification, waiting for dust to settle")] reason = "matches collection reform specification, waiting for dust to settle")]
pub fn range_mut<'a>(&'a mut self, min: Bound<&K>, max: Bound<&K>) -> RangeMut<'a, K, V> { pub fn range_mut<'a>(&'a mut self, min: Bound<&K>, max: Bound<&K>) -> RangeMut<'a, K, V> {
range_impl!(&mut self.root, min, max, as_slices_internal_mut, iter_mut, RangeMut, range_impl!(&mut self.root, min, max, as_slices_internal_mut, iter_mut, RangeMut,

View File

@ -102,7 +102,7 @@ impl<T: Ord> BTreeSet<T> {
/// Makes a new BTreeSet with the given B. /// Makes a new BTreeSet with the given B.
/// ///
/// B cannot be less than 2. /// B cannot be less than 2.
#[unstable(feature = "collections", #[unstable(feature = "btree_b",
reason = "probably want this to be on the type, eventually")] reason = "probably want this to be on the type, eventually")]
pub fn with_b(b: usize) -> BTreeSet<T> { pub fn with_b(b: usize) -> BTreeSet<T> {
BTreeSet { map: BTreeMap::with_b(b) } BTreeSet { map: BTreeMap::with_b(b) }
@ -154,7 +154,7 @@ impl<T: Ord> BTreeSet<T> {
/// } /// }
/// assert_eq!(Some(&5), set.range(Included(&4), Unbounded).next()); /// assert_eq!(Some(&5), set.range(Included(&4), Unbounded).next());
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "btree_range",
reason = "matches collection reform specification, waiting for dust to settle")] reason = "matches collection reform specification, waiting for dust to settle")]
pub fn range<'a>(&'a self, min: Bound<&T>, max: Bound<&T>) -> Range<'a, T> { pub fn range<'a>(&'a self, min: Bound<&T>, max: Bound<&T>) -> Range<'a, T> {
fn first<A, B>((a, _): (A, B)) -> A { a } fn first<A, B>((a, _): (A, B)) -> A { a }

View File

@ -13,21 +13,26 @@
//! This module defines a container which uses an efficient bit mask //! This module defines a container which uses an efficient bit mask
//! representation to hold C-like enum variants. //! representation to hold C-like enum variants.
#![unstable(feature = "enumset",
reason = "matches collection reform specification, \
waiting for dust to settle")]
use core::prelude::*; use core::prelude::*;
use core::marker; use core::marker;
use core::fmt; use core::fmt;
use core::iter::{FromIterator}; use core::iter::{FromIterator};
use core::ops::{Sub, BitOr, BitAnd, BitXor}; use core::ops::{Sub, BitOr, BitAnd, BitXor};
// FIXME(contentions): implement union family of methods? (general design may be wrong here) // FIXME(contentions): implement union family of methods? (general design may be
// wrong here)
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
/// A specialized set implementation to use enum types. /// A specialized set implementation to use enum types.
/// ///
/// It is a logic error for an item to be modified in such a way that the transformation of the /// It is a logic error for an item to be modified in such a way that the
/// item to or from a `usize`, as determined by the `CLike` trait, changes while the item is in the /// transformation of the item to or from a `usize`, as determined by the
/// set. This is normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe /// `CLike` trait, changes while the item is in the set. This is normally only
/// code. /// possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct EnumSet<E> { pub struct EnumSet<E> {
// We must maintain the invariant that no bits are set // We must maintain the invariant that no bits are set
// for which no variant exists // for which no variant exists
@ -93,22 +98,16 @@ fn bit<E:CLike>(e: &E) -> usize {
impl<E:CLike> EnumSet<E> { impl<E:CLike> EnumSet<E> {
/// Returns an empty `EnumSet`. /// Returns an empty `EnumSet`.
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn new() -> EnumSet<E> { pub fn new() -> EnumSet<E> {
EnumSet {bits: 0, marker: marker::PhantomData} EnumSet {bits: 0, marker: marker::PhantomData}
} }
/// Returns the number of elements in the given `EnumSet`. /// Returns the number of elements in the given `EnumSet`.
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.bits.count_ones() as usize self.bits.count_ones() as usize
} }
/// Returns true if the `EnumSet` is empty. /// Returns true if the `EnumSet` is empty.
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.bits == 0 self.bits == 0
} }
@ -118,22 +117,16 @@ impl<E:CLike> EnumSet<E> {
} }
/// Returns `false` if the `EnumSet` contains any enum of the given `EnumSet`. /// Returns `false` if the `EnumSet` contains any enum of the given `EnumSet`.
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn is_disjoint(&self, other: &EnumSet<E>) -> bool { pub fn is_disjoint(&self, other: &EnumSet<E>) -> bool {
(self.bits & other.bits) == 0 (self.bits & other.bits) == 0
} }
/// Returns `true` if a given `EnumSet` is included in this `EnumSet`. /// Returns `true` if a given `EnumSet` is included in this `EnumSet`.
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn is_superset(&self, other: &EnumSet<E>) -> bool { pub fn is_superset(&self, other: &EnumSet<E>) -> bool {
(self.bits & other.bits) == other.bits (self.bits & other.bits) == other.bits
} }
/// Returns `true` if this `EnumSet` is included in the given `EnumSet`. /// Returns `true` if this `EnumSet` is included in the given `EnumSet`.
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn is_subset(&self, other: &EnumSet<E>) -> bool { pub fn is_subset(&self, other: &EnumSet<E>) -> bool {
other.is_superset(self) other.is_superset(self)
} }
@ -151,8 +144,6 @@ impl<E:CLike> EnumSet<E> {
} }
/// Adds an enum to the `EnumSet`, and returns `true` if it wasn't there before /// Adds an enum to the `EnumSet`, and returns `true` if it wasn't there before
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn insert(&mut self, e: E) -> bool { pub fn insert(&mut self, e: E) -> bool {
let result = !self.contains(&e); let result = !self.contains(&e);
self.bits |= bit(&e); self.bits |= bit(&e);
@ -160,8 +151,6 @@ impl<E:CLike> EnumSet<E> {
} }
/// Removes an enum from the EnumSet /// Removes an enum from the EnumSet
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn remove(&mut self, e: &E) -> bool { pub fn remove(&mut self, e: &E) -> bool {
let result = self.contains(e); let result = self.contains(e);
self.bits &= !bit(e); self.bits &= !bit(e);
@ -169,15 +158,11 @@ impl<E:CLike> EnumSet<E> {
} }
/// Returns `true` if an `EnumSet` contains a given enum. /// Returns `true` if an `EnumSet` contains a given enum.
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn contains(&self, e: &E) -> bool { pub fn contains(&self, e: &E) -> bool {
(self.bits & bit(e)) != 0 (self.bits & bit(e)) != 0
} }
/// Returns an iterator over an `EnumSet`. /// Returns an iterator over an `EnumSet`.
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn iter(&self) -> Iter<E> { pub fn iter(&self) -> Iter<E> {
Iter::new(self.bits) Iter::new(self.bits)
} }

View File

@ -10,14 +10,17 @@
//! Collection types. //! Collection types.
//! //!
//! See [std::collections](../std/collections) for a detailed discussion of collections in Rust. //! See [std::collections](../std/collections) for a detailed discussion of
//! collections in Rust.
// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) // Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)
#![cfg_attr(stage0, feature(custom_attribute))] #![cfg_attr(stage0, feature(custom_attribute))]
#![crate_name = "collections"] #![crate_name = "collections"]
#![unstable(feature = "collections")]
#![staged_api] #![staged_api]
#![crate_type = "rlib"] #![crate_type = "rlib"]
#![unstable(feature = "collections",
reason = "library is unlikely to be stabilized with the current \
layout and name, use std::collections instead")]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/", html_root_url = "http://doc.rust-lang.org/nightly/",
@ -107,14 +110,12 @@ pub mod vec;
pub mod vec_deque; pub mod vec_deque;
pub mod vec_map; pub mod vec_map;
#[unstable(feature = "collections", #[unstable(feature = "bitvec", reason = "RFC 509")]
reason = "RFC 509")]
pub mod bit_vec { pub mod bit_vec {
pub use bit::{BitVec, Iter}; pub use bit::{BitVec, Iter};
} }
#[unstable(feature = "collections", #[unstable(feature = "bitset", reason = "RFC 509")]
reason = "RFC 509")]
pub mod bit_set { pub mod bit_set {
pub use bit::{BitSet, Union, Intersection, Difference, SymmetricDifference}; pub use bit::{BitSet, Union, Intersection, Difference, SymmetricDifference};
pub use bit::SetIter as Iter; pub use bit::SetIter as Iter;
@ -133,6 +134,7 @@ pub mod btree_set {
// FIXME(#14344) this shouldn't be necessary // FIXME(#14344) this shouldn't be necessary
#[doc(hidden)] #[doc(hidden)]
#[unstable(feature = "issue_14344_fixme")]
pub fn fixme_14344_be_sure_to_link_to_collections() {} pub fn fixme_14344_be_sure_to_link_to_collections() {}
#[cfg(not(test))] #[cfg(not(test))]
@ -141,6 +143,7 @@ mod std {
} }
/// An endpoint of a range of keys. /// An endpoint of a range of keys.
#[unstable(feature = "collections_bound")]
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub enum Bound<T> { pub enum Bound<T> {
/// An inclusive bound. /// An inclusive bound.

View File

@ -801,7 +801,7 @@ impl<'a, A> IterMut<'a, A> {
/// } /// }
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "collections", #[unstable(feature = "linked_list_extras",
reason = "this is probably better handled by a cursor type -- we'll see")] reason = "this is probably better handled by a cursor type -- we'll see")]
pub fn insert_next(&mut self, elt: A) { pub fn insert_next(&mut self, elt: A) {
self.insert_next_node(box Node::new(elt)) self.insert_next_node(box Node::new(elt))
@ -824,7 +824,7 @@ impl<'a, A> IterMut<'a, A> {
/// assert_eq!(it.next().unwrap(), &2); /// assert_eq!(it.next().unwrap(), &2);
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "collections", #[unstable(feature = "linked_list_extras",
reason = "this is probably better handled by a cursor type -- we'll see")] reason = "this is probably better handled by a cursor type -- we'll see")]
pub fn peek_next(&mut self) -> Option<&mut A> { pub fn peek_next(&mut self) -> Option<&mut A> {
if self.nelem == 0 { if self.nelem == 0 {

View File

@ -7,6 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![unstable(feature = "collections_range", reason = "was just added")] #![unstable(feature = "collections_range", reason = "was just added")]
//! Range syntax. //! Range syntax.

View File

@ -11,7 +11,8 @@
//! Utilities for slice manipulation //! Utilities for slice manipulation
//! //!
//! The `slice` module contains useful code to help work with slice values. //! The `slice` module contains useful code to help work with slice values.
//! Slices are a view into a block of memory represented as a pointer and a length. //! Slices are a view into a block of memory represented as a pointer and a
//! length.
//! //!
//! ``` //! ```
//! // slicing a Vec //! // slicing a Vec
@ -69,8 +70,9 @@
//! } //! }
//! ``` //! ```
//! //!
//! This iterator yields mutable references to the slice's elements, so while the element //! This iterator yields mutable references to the slice's elements, so while
//! type of the slice is `i32`, the element type of the iterator is `&mut i32`. //! the element type of the slice is `i32`, the element type of the iterator is
//! `&mut i32`.
//! //!
//! * `.iter()` and `.iter_mut()` are the explicit methods to return the default //! * `.iter()` and `.iter_mut()` are the explicit methods to return the default
//! iterators. //! iterators.
@ -278,14 +280,14 @@ impl<T> [T] {
} }
/// Returns all but the first element of a slice. /// Returns all but the first element of a slice.
#[unstable(feature = "collections", reason = "likely to be renamed")] #[unstable(feature = "slice_extras", reason = "likely to be renamed")]
#[inline] #[inline]
pub fn tail(&self) -> &[T] { pub fn tail(&self) -> &[T] {
core_slice::SliceExt::tail(self) core_slice::SliceExt::tail(self)
} }
/// Returns all but the first element of a mutable slice /// Returns all but the first element of a mutable slice
#[unstable(feature = "collections", #[unstable(feature = "slice_extras",
reason = "likely to be renamed or removed")] reason = "likely to be renamed or removed")]
#[inline] #[inline]
pub fn tail_mut(&mut self) -> &mut [T] { pub fn tail_mut(&mut self) -> &mut [T] {
@ -293,14 +295,14 @@ impl<T> [T] {
} }
/// Returns all but the last element of a slice. /// Returns all but the last element of a slice.
#[unstable(feature = "collections", reason = "likely to be renamed")] #[unstable(feature = "slice_extras", reason = "likely to be renamed")]
#[inline] #[inline]
pub fn init(&self) -> &[T] { pub fn init(&self) -> &[T] {
core_slice::SliceExt::init(self) core_slice::SliceExt::init(self)
} }
/// Returns all but the last element of a mutable slice /// Returns all but the last element of a mutable slice
#[unstable(feature = "collections", #[unstable(feature = "slice_extras",
reason = "likely to be renamed or removed")] reason = "likely to be renamed or removed")]
#[inline] #[inline]
pub fn init_mut(&mut self) -> &mut [T] { pub fn init_mut(&mut self) -> &mut [T] {
@ -727,13 +729,13 @@ impl<T> [T] {
} }
/// Find the first index containing a matching value. /// Find the first index containing a matching value.
#[unstable(feature = "collections")] #[unstable(feature = "slice_position_elem")]
pub fn position_elem(&self, t: &T) -> Option<usize> where T: PartialEq { pub fn position_elem(&self, t: &T) -> Option<usize> where T: PartialEq {
core_slice::SliceExt::position_elem(self, t) core_slice::SliceExt::position_elem(self, t)
} }
/// Find the last index containing a matching value. /// Find the last index containing a matching value.
#[unstable(feature = "collections")] #[unstable(feature = "slice_position_elem")]
pub fn rposition_elem(&self, t: &T) -> Option<usize> where T: PartialEq { pub fn rposition_elem(&self, t: &T) -> Option<usize> where T: PartialEq {
core_slice::SliceExt::rposition_elem(self, t) core_slice::SliceExt::rposition_elem(self, t)
} }
@ -869,7 +871,7 @@ impl<T> [T] {
/// assert_eq!(Some(vec![1, 3, 2]), perms.next()); /// assert_eq!(Some(vec![1, 3, 2]), perms.next());
/// assert_eq!(Some(vec![3, 1, 2]), perms.next()); /// assert_eq!(Some(vec![3, 1, 2]), perms.next());
/// ``` /// ```
#[unstable(feature = "collections")] #[unstable(feature = "permutations")]
#[inline] #[inline]
pub fn permutations(&self) -> Permutations<T> where T: Clone { pub fn permutations(&self) -> Permutations<T> where T: Clone {
// NB see hack module in this file // NB see hack module in this file
@ -893,7 +895,7 @@ impl<T> [T] {
/// let b: &mut [_] = &mut [1, 0, 2]; /// let b: &mut [_] = &mut [1, 0, 2];
/// assert!(v == b); /// assert!(v == b);
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "permutations",
reason = "uncertain if this merits inclusion in std")] reason = "uncertain if this merits inclusion in std")]
pub fn next_permutation(&mut self) -> bool where T: Ord { pub fn next_permutation(&mut self) -> bool where T: Ord {
core_slice::SliceExt::next_permutation(self) core_slice::SliceExt::next_permutation(self)
@ -916,7 +918,7 @@ impl<T> [T] {
/// let b: &mut [_] = &mut [0, 1, 2]; /// let b: &mut [_] = &mut [0, 1, 2];
/// assert!(v == b); /// assert!(v == b);
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "permutations",
reason = "uncertain if this merits inclusion in std")] reason = "uncertain if this merits inclusion in std")]
pub fn prev_permutation(&mut self) -> bool where T: Ord { pub fn prev_permutation(&mut self) -> bool where T: Ord {
core_slice::SliceExt::prev_permutation(self) core_slice::SliceExt::prev_permutation(self)
@ -940,7 +942,7 @@ impl<T> [T] {
/// assert!(dst.clone_from_slice(&src2) == 3); /// assert!(dst.clone_from_slice(&src2) == 3);
/// assert!(dst == [3, 4, 5]); /// assert!(dst == [3, 4, 5]);
/// ``` /// ```
#[unstable(feature = "collections")] #[unstable(feature = "clone_from_slice")]
pub fn clone_from_slice(&mut self, src: &[T]) -> usize where T: Clone { pub fn clone_from_slice(&mut self, src: &[T]) -> usize where T: Clone {
core_slice::SliceExt::clone_from_slice(self, src) core_slice::SliceExt::clone_from_slice(self, src)
} }
@ -967,7 +969,7 @@ impl<T> [T] {
/// assert_eq!(num_moved, 3); /// assert_eq!(num_moved, 3);
/// assert!(a == [6, 7, 8, 4, 5]); /// assert!(a == [6, 7, 8, 4, 5]);
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "move_from",
reason = "uncertain about this API approach")] reason = "uncertain about this API approach")]
#[inline] #[inline]
pub fn move_from(&mut self, mut src: Vec<T>, start: usize, end: usize) -> usize { pub fn move_from(&mut self, mut src: Vec<T>, start: usize, end: usize) -> usize {
@ -997,10 +999,12 @@ impl<T> [T] {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Extension traits for slices over specific kinds of data // Extension traits for slices over specific kinds of data
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#[unstable(feature = "collections", reason = "recently changed")] #[unstable(feature = "slice_concat_ext",
reason = "trait should not have to exist")]
/// An extension trait for concatenating slices /// An extension trait for concatenating slices
pub trait SliceConcatExt<T: ?Sized> { pub trait SliceConcatExt<T: ?Sized> {
#[unstable(feature = "collections", reason = "recently changed")] #[unstable(feature = "slice_concat_ext",
reason = "trait should not have to exist")]
/// The resulting type after concatenation /// The resulting type after concatenation
type Output; type Output;
@ -1014,8 +1018,8 @@ pub trait SliceConcatExt<T: ?Sized> {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
fn concat(&self) -> Self::Output; fn concat(&self) -> Self::Output;
/// Flattens a slice of `T` into a single value `Self::Output`, placing a given separator /// Flattens a slice of `T` into a single value `Self::Output`, placing a
/// between each. /// given separator between each.
/// ///
/// # Examples /// # Examples
/// ///
@ -1060,7 +1064,7 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
/// ///
/// The last generated swap is always (0, 1), and it returns the /// The last generated swap is always (0, 1), and it returns the
/// sequence to its initial order. /// sequence to its initial order.
#[unstable(feature = "collections")] #[unstable(feature = "permutations")]
#[derive(Clone)] #[derive(Clone)]
pub struct ElementSwaps { pub struct ElementSwaps {
sdir: Vec<SizeDirection>, sdir: Vec<SizeDirection>,
@ -1072,7 +1076,7 @@ pub struct ElementSwaps {
impl ElementSwaps { impl ElementSwaps {
/// Creates an `ElementSwaps` iterator for a sequence of `length` elements. /// Creates an `ElementSwaps` iterator for a sequence of `length` elements.
#[unstable(feature = "collections")] #[unstable(feature = "permutations")]
pub fn new(length: usize) -> ElementSwaps { pub fn new(length: usize) -> ElementSwaps {
// Initialize `sdir` with a direction that position should move in // Initialize `sdir` with a direction that position should move in
// (all negative at the beginning) and the `size` of the // (all negative at the beginning) and the `size` of the
@ -1194,13 +1198,13 @@ impl Iterator for ElementSwaps {
/// swap applied. /// swap applied.
/// ///
/// Generates even and odd permutations alternately. /// Generates even and odd permutations alternately.
#[unstable(feature = "collections")] #[unstable(feature = "permutations")]
pub struct Permutations<T> { pub struct Permutations<T> {
swaps: ElementSwaps, swaps: ElementSwaps,
v: Vec<T>, v: Vec<T>,
} }
#[unstable(feature = "collections", reason = "trait is unstable")] #[unstable(feature = "permutations", reason = "trait is unstable")]
impl<T: Clone> Iterator for Permutations<T> { impl<T: Clone> Iterator for Permutations<T> {
type Item = Vec<T>; type Item = Vec<T>;

View File

@ -366,7 +366,7 @@ impl<'a> Iterator for Recompositions<'a> {
/// ///
/// For use with the `std::iter` module. /// For use with the `std::iter` module.
#[derive(Clone)] #[derive(Clone)]
#[unstable(feature = "collections")] #[unstable(feature = "str_utf16")]
pub struct Utf16Units<'a> { pub struct Utf16Units<'a> {
encoder: Utf16Encoder<Chars<'a>> encoder: Utf16Encoder<Chars<'a>>
} }
@ -591,7 +591,7 @@ impl str {
/// assert_eq!(s.slice_chars(0, 4), "Löwe"); /// assert_eq!(s.slice_chars(0, 4), "Löwe");
/// assert_eq!(s.slice_chars(5, 7), "老虎"); /// assert_eq!(s.slice_chars(5, 7), "老虎");
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "slice_chars",
reason = "may have yet to prove its worth")] reason = "may have yet to prove its worth")]
pub fn slice_chars(&self, begin: usize, end: usize) -> &str { pub fn slice_chars(&self, begin: usize, end: usize) -> &str {
core_str::StrExt::slice_chars(self, begin, end) core_str::StrExt::slice_chars(self, begin, end)
@ -1068,7 +1068,7 @@ impl str {
} }
/// Returns an iterator of `u16` over the string encoded as UTF-16. /// Returns an iterator of `u16` over the string encoded as UTF-16.
#[unstable(feature = "collections", #[unstable(feature = "str_utf16",
reason = "this functionality may only be provided by libunicode")] reason = "this functionality may only be provided by libunicode")]
pub fn utf16_units(&self) -> Utf16Units { pub fn utf16_units(&self) -> Utf16Units {
Utf16Units { encoder: Utf16Encoder::new(self[..].chars()) } Utf16Units { encoder: Utf16Encoder::new(self[..].chars()) }
@ -1527,7 +1527,7 @@ impl str {
/// let v: Vec<&str> = "1abc2abc3".matches(char::is_numeric).collect(); /// let v: Vec<&str> = "1abc2abc3".matches(char::is_numeric).collect();
/// assert_eq!(v, ["1", "2", "3"]); /// assert_eq!(v, ["1", "2", "3"]);
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "str_matches",
reason = "method got recently added")] reason = "method got recently added")]
pub fn matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> Matches<'a, P> { pub fn matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> Matches<'a, P> {
core_str::StrExt::matches(self, pat) core_str::StrExt::matches(self, pat)
@ -1560,7 +1560,7 @@ impl str {
/// let v: Vec<&str> = "1abc2abc3".rmatches(char::is_numeric).collect(); /// let v: Vec<&str> = "1abc2abc3".rmatches(char::is_numeric).collect();
/// assert_eq!(v, ["3", "2", "1"]); /// assert_eq!(v, ["3", "2", "1"]);
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "str_matches",
reason = "method got recently added")] reason = "method got recently added")]
pub fn rmatches<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatches<'a, P> pub fn rmatches<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatches<'a, P>
where P::Searcher: ReverseSearcher<'a> where P::Searcher: ReverseSearcher<'a>
@ -1605,7 +1605,7 @@ impl str {
/// let v: Vec<(usize, usize)> = "ababa".match_indices("aba").collect(); /// let v: Vec<(usize, usize)> = "ababa".match_indices("aba").collect();
/// assert_eq!(v, [(0, 3)]); // only the first `aba` /// assert_eq!(v, [(0, 3)]); // only the first `aba`
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "str_matches",
reason = "might have its iterator type changed")] reason = "might have its iterator type changed")]
// NB: Right now MatchIndices yields `(usize, usize)`, but it would // NB: Right now MatchIndices yields `(usize, usize)`, but it would
// be more consistent with `matches` and `char_indices` to return `(usize, &str)` // be more consistent with `matches` and `char_indices` to return `(usize, &str)`
@ -1649,7 +1649,7 @@ impl str {
/// let v: Vec<(usize, usize)> = "ababa".rmatch_indices("aba").collect(); /// let v: Vec<(usize, usize)> = "ababa".rmatch_indices("aba").collect();
/// assert_eq!(v, [(2, 5)]); // only the last `aba` /// assert_eq!(v, [(2, 5)]); // only the last `aba`
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "str_matches",
reason = "might have its iterator type changed")] reason = "might have its iterator type changed")]
// NB: Right now RMatchIndices yields `(usize, usize)`, but it would // NB: Right now RMatchIndices yields `(usize, usize)`, but it would
// be more consistent with `rmatches` and `char_indices` to return `(usize, &str)` // be more consistent with `rmatches` and `char_indices` to return `(usize, &str)`
@ -1677,7 +1677,7 @@ impl str {
/// assert!(string.subslice_offset(lines[1]) == 2); // &"b" /// assert!(string.subslice_offset(lines[1]) == 2); // &"b"
/// assert!(string.subslice_offset(lines[2]) == 4); // &"c" /// assert!(string.subslice_offset(lines[2]) == 4); // &"c"
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "subslice_offset",
reason = "awaiting convention about comparability of arbitrary slices")] reason = "awaiting convention about comparability of arbitrary slices")]
pub fn subslice_offset(&self, inner: &str) -> usize { pub fn subslice_offset(&self, inner: &str) -> usize {
core_str::StrExt::subslice_offset(self, inner) core_str::StrExt::subslice_offset(self, inner)
@ -1922,14 +1922,14 @@ impl str {
} }
/// Escapes each char in `s` with `char::escape_default`. /// Escapes each char in `s` with `char::escape_default`.
#[unstable(feature = "collections", #[unstable(feature = "str_escape",
reason = "return type may change to be an iterator")] reason = "return type may change to be an iterator")]
pub fn escape_default(&self) -> String { pub fn escape_default(&self) -> String {
self.chars().flat_map(|c| c.escape_default()).collect() self.chars().flat_map(|c| c.escape_default()).collect()
} }
/// Escapes each char in `s` with `char::escape_unicode`. /// Escapes each char in `s` with `char::escape_unicode`.
#[unstable(feature = "collections", #[unstable(feature = "str_escape",
reason = "return type may change to be an iterator")] reason = "return type may change to be an iterator")]
pub fn escape_unicode(&self) -> String { pub fn escape_unicode(&self) -> String {
self.chars().flat_map(|c| c.escape_unicode()).collect() self.chars().flat_map(|c| c.escape_unicode()).collect()

View File

@ -696,7 +696,7 @@ impl String {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections_drain)] /// # #![feature(drain)]
/// ///
/// let mut s = String::from("α is alpha, β is beta"); /// let mut s = String::from("α is alpha, β is beta");
/// let beta_offset = s.find('β').unwrap_or(s.len()); /// let beta_offset = s.find('β').unwrap_or(s.len());
@ -710,7 +710,7 @@ impl String {
/// s.drain(..); /// s.drain(..);
/// assert_eq!(s, ""); /// assert_eq!(s, "");
/// ``` /// ```
#[unstable(feature = "collections_drain", #[unstable(feature = "drain",
reason = "recently added, matches RFC")] reason = "recently added, matches RFC")]
pub fn drain<R>(&mut self, range: R) -> Drain where R: RangeArgument<usize> { pub fn drain<R>(&mut self, range: R) -> Drain where R: RangeArgument<usize> {
// Memory safety // Memory safety
@ -975,10 +975,14 @@ impl ops::Deref for String {
/// Wrapper type providing a `&String` reference via `Deref`. /// Wrapper type providing a `&String` reference via `Deref`.
#[unstable(feature = "collections")] #[unstable(feature = "collections")]
#[deprecated(since = "1.2.0",
reason = "replaced with deref coercions or Borrow")]
#[allow(deprecated)]
pub struct DerefString<'a> { pub struct DerefString<'a> {
x: DerefVec<'a, u8> x: DerefVec<'a, u8>
} }
#[allow(deprecated)]
impl<'a> Deref for DerefString<'a> { impl<'a> Deref for DerefString<'a> {
type Target = String; type Target = String;
@ -1005,6 +1009,9 @@ impl<'a> Deref for DerefString<'a> {
/// string_consumer(&as_string("foo")); /// string_consumer(&as_string("foo"));
/// ``` /// ```
#[unstable(feature = "collections")] #[unstable(feature = "collections")]
#[deprecated(since = "1.2.0",
reason = "replaced with deref coercions or Borrow")]
#[allow(deprecated)]
pub fn as_string<'a>(x: &'a str) -> DerefString<'a> { pub fn as_string<'a>(x: &'a str) -> DerefString<'a> {
DerefString { x: as_vec(x.as_bytes()) } DerefString { x: as_vec(x.as_bytes()) }
} }
@ -1134,7 +1141,7 @@ impl fmt::Write for String {
} }
/// A draining iterator for `String`. /// A draining iterator for `String`.
#[unstable(feature = "collections_drain", reason = "recently added")] #[unstable(feature = "drain", reason = "recently added")]
pub struct Drain<'a> { pub struct Drain<'a> {
/// Will be used as &'a mut String in the destructor /// Will be used as &'a mut String in the destructor
string: *mut String, string: *mut String,
@ -1149,7 +1156,7 @@ pub struct Drain<'a> {
unsafe impl<'a> Sync for Drain<'a> {} unsafe impl<'a> Sync for Drain<'a> {}
unsafe impl<'a> Send for Drain<'a> {} unsafe impl<'a> Send for Drain<'a> {}
#[unstable(feature = "collections_drain", reason = "recently added")] #[unstable(feature = "drain", reason = "recently added")]
impl<'a> Drop for Drain<'a> { impl<'a> Drop for Drain<'a> {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
@ -1163,7 +1170,7 @@ impl<'a> Drop for Drain<'a> {
} }
} }
#[unstable(feature = "collections_drain", reason = "recently added")] #[unstable(feature = "drain", reason = "recently added")]
impl<'a> Iterator for Drain<'a> { impl<'a> Iterator for Drain<'a> {
type Item = char; type Item = char;
@ -1177,7 +1184,7 @@ impl<'a> Iterator for Drain<'a> {
} }
} }
#[unstable(feature = "collections_drain", reason = "recently added")] #[unstable(feature = "drain", reason = "recently added")]
impl<'a> DoubleEndedIterator for Drain<'a> { impl<'a> DoubleEndedIterator for Drain<'a> {
#[inline] #[inline]
fn next_back(&mut self) -> Option<char> { fn next_back(&mut self) -> Option<char> {

View File

@ -276,7 +276,7 @@ impl<T> Vec<T> {
/// the buffer are copied into the vector without cloning, as if /// the buffer are copied into the vector without cloning, as if
/// `ptr::read()` were called on them. /// `ptr::read()` were called on them.
#[inline] #[inline]
#[unstable(feature = "collections", #[unstable(feature = "vec_from_raw_buf",
reason = "may be better expressed via composition")] reason = "may be better expressed via composition")]
pub unsafe fn from_raw_buf(ptr: *const T, elts: usize) -> Vec<T> { pub unsafe fn from_raw_buf(ptr: *const T, elts: usize) -> Vec<T> {
let mut dst = Vec::with_capacity(elts); let mut dst = Vec::with_capacity(elts);
@ -704,7 +704,7 @@ impl<T> Vec<T> {
/// assert_eq!(vec2, []); /// assert_eq!(vec2, []);
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "collections", #[unstable(feature = "append",
reason = "new API, waiting for dust to settle")] reason = "new API, waiting for dust to settle")]
pub fn append(&mut self, other: &mut Self) { pub fn append(&mut self, other: &mut Self) {
if mem::size_of::<T>() == 0 { if mem::size_of::<T>() == 0 {
@ -742,7 +742,7 @@ impl<T> Vec<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections_drain)] /// # #![feature(drain)]
/// ///
/// // Draining using `..` clears the whole vector. /// // Draining using `..` clears the whole vector.
/// let mut v = vec![1, 2, 3]; /// let mut v = vec![1, 2, 3];
@ -750,7 +750,7 @@ impl<T> Vec<T> {
/// assert_eq!(v, &[]); /// assert_eq!(v, &[]);
/// assert_eq!(u, &[1, 2, 3]); /// assert_eq!(u, &[1, 2, 3]);
/// ``` /// ```
#[unstable(feature = "collections_drain", #[unstable(feature = "drain",
reason = "recently added, matches RFC")] reason = "recently added, matches RFC")]
pub fn drain<R>(&mut self, range: R) -> Drain<T> where R: RangeArgument<usize> { pub fn drain<R>(&mut self, range: R) -> Drain<T> where R: RangeArgument<usize> {
// Memory safety // Memory safety
@ -851,7 +851,7 @@ impl<T> Vec<T> {
/// let newtyped_bytes = bytes.map_in_place(|x| Newtype(x)); /// let newtyped_bytes = bytes.map_in_place(|x| Newtype(x));
/// assert_eq!(&newtyped_bytes[..], &[Newtype(0x11), Newtype(0x22)]); /// assert_eq!(&newtyped_bytes[..], &[Newtype(0x11), Newtype(0x22)]);
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "map_in_place",
reason = "API may change to provide stronger guarantees")] reason = "API may change to provide stronger guarantees")]
pub fn map_in_place<U, F>(self, mut f: F) -> Vec<U> where F: FnMut(T) -> U { pub fn map_in_place<U, F>(self, mut f: F) -> Vec<U> where F: FnMut(T) -> U {
// FIXME: Assert statically that the types `T` and `U` have the same // FIXME: Assert statically that the types `T` and `U` have the same
@ -1043,14 +1043,14 @@ impl<T> Vec<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)] /// # #![feature(split_off)]
/// let mut vec = vec![1,2,3]; /// let mut vec = vec![1,2,3];
/// let vec2 = vec.split_off(1); /// let vec2 = vec.split_off(1);
/// assert_eq!(vec, [1]); /// assert_eq!(vec, [1]);
/// assert_eq!(vec2, [2, 3]); /// assert_eq!(vec2, [2, 3]);
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "collections", #[unstable(feature = "split_off",
reason = "new API, waiting for dust to settle")] reason = "new API, waiting for dust to settle")]
pub fn split_off(&mut self, at: usize) -> Self { pub fn split_off(&mut self, at: usize) -> Self {
assert!(at <= self.len(), "`at` out of bounds"); assert!(at <= self.len(), "`at` out of bounds");
@ -1091,7 +1091,7 @@ impl<T: Clone> Vec<T> {
/// vec.resize(2, 0); /// vec.resize(2, 0);
/// assert_eq!(vec, [1, 2]); /// assert_eq!(vec, [1, 2]);
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "vec_resize",
reason = "matches collection reform specification; waiting for dust to settle")] reason = "matches collection reform specification; waiting for dust to settle")]
pub fn resize(&mut self, new_len: usize, value: T) { pub fn resize(&mut self, new_len: usize, value: T) {
let len = self.len(); let len = self.len();
@ -1117,7 +1117,7 @@ impl<T: Clone> Vec<T> {
/// assert_eq!(vec, [1, 2, 3, 4]); /// assert_eq!(vec, [1, 2, 3, 4]);
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "collections", #[unstable(feature = "vec_push_all",
reason = "likely to be replaced by a more optimized extend")] reason = "likely to be replaced by a more optimized extend")]
pub fn push_all(&mut self, other: &[T]) { pub fn push_all(&mut self, other: &[T]) {
self.reserve(other.len()); self.reserve(other.len());
@ -1738,7 +1738,7 @@ unsafe impl<T: Sync> Sync for IntoIter<T> { }
impl<T> IntoIter<T> { impl<T> IntoIter<T> {
#[inline] #[inline]
/// Drops all items that have not yet been moved and returns the empty vector. /// Drops all items that have not yet been moved and returns the empty vector.
#[unstable(feature = "collections")] #[unstable(feature = "iter_to_vec")]
pub fn into_inner(mut self) -> Vec<T> { pub fn into_inner(mut self) -> Vec<T> {
unsafe { unsafe {
for _x in self.by_ref() { } for _x in self.by_ref() { }
@ -1832,7 +1832,7 @@ impl<T> Drop for IntoIter<T> {
} }
/// A draining iterator for `Vec<T>`. /// A draining iterator for `Vec<T>`.
#[unstable(feature = "collections_drain", reason = "recently added")] #[unstable(feature = "drain", reason = "recently added")]
pub struct Drain<'a, T: 'a> { pub struct Drain<'a, T: 'a> {
/// Index of tail to preserve /// Index of tail to preserve
tail_start: usize, tail_start: usize,
@ -1907,12 +1907,17 @@ impl<'a, T> ExactSizeIterator for Drain<'a, T> {}
/// Wrapper type providing a `&Vec<T>` reference via `Deref`. /// Wrapper type providing a `&Vec<T>` reference via `Deref`.
#[unstable(feature = "collections")] #[unstable(feature = "collections")]
#[deprecated(since = "1.2.0",
reason = "replaced with deref coercions or Borrow")]
pub struct DerefVec<'a, T:'a> { pub struct DerefVec<'a, T:'a> {
x: Vec<T>, x: Vec<T>,
l: PhantomData<&'a T>, l: PhantomData<&'a T>,
} }
#[unstable(feature = "collections")] #[unstable(feature = "collections")]
#[deprecated(since = "1.2.0",
reason = "replaced with deref coercions or Borrow")]
#[allow(deprecated)]
impl<'a, T> Deref for DerefVec<'a, T> { impl<'a, T> Deref for DerefVec<'a, T> {
type Target = Vec<T>; type Target = Vec<T>;
@ -1923,6 +1928,9 @@ impl<'a, T> Deref for DerefVec<'a, T> {
// Prevent the inner `Vec<T>` from attempting to deallocate memory. // Prevent the inner `Vec<T>` from attempting to deallocate memory.
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[deprecated(since = "1.2.0",
reason = "replaced with deref coercions or Borrow")]
#[allow(deprecated)]
impl<'a, T> Drop for DerefVec<'a, T> { impl<'a, T> Drop for DerefVec<'a, T> {
fn drop(&mut self) { fn drop(&mut self) {
self.x.len = 0; self.x.len = 0;
@ -1948,6 +1956,9 @@ impl<'a, T> Drop for DerefVec<'a, T> {
/// vec_consumer(&as_vec(&values)); /// vec_consumer(&as_vec(&values));
/// ``` /// ```
#[unstable(feature = "collections")] #[unstable(feature = "collections")]
#[deprecated(since = "1.2.0",
reason = "replaced with deref coercions or Borrow")]
#[allow(deprecated)]
pub fn as_vec<'a, T>(x: &'a [T]) -> DerefVec<'a, T> { pub fn as_vec<'a, T>(x: &'a [T]) -> DerefVec<'a, T> {
unsafe { unsafe {
DerefVec { DerefVec {

View File

@ -491,7 +491,7 @@ impl<T> VecDeque<T> {
/// assert_eq!(buf.len(), 1); /// assert_eq!(buf.len(), 1);
/// assert_eq!(Some(&5), buf.get(0)); /// assert_eq!(Some(&5), buf.get(0));
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "deque_extras",
reason = "matches collection reform specification; waiting on panic semantics")] reason = "matches collection reform specification; waiting on panic semantics")]
pub fn truncate(&mut self, len: usize) { pub fn truncate(&mut self, len: usize) {
for _ in len..self.len() { for _ in len..self.len() {
@ -552,7 +552,7 @@ impl<T> VecDeque<T> {
/// Returns a pair of slices which contain, in order, the contents of the /// Returns a pair of slices which contain, in order, the contents of the
/// `VecDeque`. /// `VecDeque`.
#[inline] #[inline]
#[unstable(feature = "collections", #[unstable(feature = "deque_extras",
reason = "matches collection reform specification, waiting for dust to settle")] reason = "matches collection reform specification, waiting for dust to settle")]
pub fn as_slices(&self) -> (&[T], &[T]) { pub fn as_slices(&self) -> (&[T], &[T]) {
unsafe { unsafe {
@ -572,7 +572,7 @@ impl<T> VecDeque<T> {
/// Returns a pair of slices which contain, in order, the contents of the /// Returns a pair of slices which contain, in order, the contents of the
/// `VecDeque`. /// `VecDeque`.
#[inline] #[inline]
#[unstable(feature = "collections", #[unstable(feature = "deque_extras",
reason = "matches collection reform specification, waiting for dust to settle")] reason = "matches collection reform specification, waiting for dust to settle")]
pub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T]) { pub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T]) {
unsafe { unsafe {
@ -638,7 +638,7 @@ impl<T> VecDeque<T> {
/// assert!(v.is_empty()); /// assert!(v.is_empty());
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "collections", #[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle")] reason = "matches collection reform specification, waiting for dust to settle")]
pub fn drain(&mut self) -> Drain<T> { pub fn drain(&mut self) -> Drain<T> {
Drain { Drain {
@ -880,7 +880,7 @@ impl<T> VecDeque<T> {
/// buf.push_back(10); /// buf.push_back(10);
/// assert_eq!(buf.swap_back_remove(1), Some(99)); /// assert_eq!(buf.swap_back_remove(1), Some(99));
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "deque_extras",
reason = "the naming of this function may be altered")] reason = "the naming of this function may be altered")]
pub fn swap_back_remove(&mut self, index: usize) -> Option<T> { pub fn swap_back_remove(&mut self, index: usize) -> Option<T> {
let length = self.len(); let length = self.len();
@ -914,7 +914,7 @@ impl<T> VecDeque<T> {
/// buf.push_back(20); /// buf.push_back(20);
/// assert_eq!(buf.swap_front_remove(3), Some(99)); /// assert_eq!(buf.swap_front_remove(3), Some(99));
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "deque_extras",
reason = "the naming of this function may be altered")] reason = "the naming of this function may be altered")]
pub fn swap_front_remove(&mut self, index: usize) -> Option<T> { pub fn swap_front_remove(&mut self, index: usize) -> Option<T> {
let length = self.len(); let length = self.len();
@ -1320,7 +1320,7 @@ impl<T> VecDeque<T> {
/// assert_eq!(buf2.len(), 2); /// assert_eq!(buf2.len(), 2);
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "collections", #[unstable(feature = "split_off",
reason = "new API, waiting for dust to settle")] reason = "new API, waiting for dust to settle")]
pub fn split_off(&mut self, at: usize) -> Self { pub fn split_off(&mut self, at: usize) -> Self {
let len = self.len(); let len = self.len();
@ -1383,7 +1383,7 @@ impl<T> VecDeque<T> {
/// assert_eq!(buf2.len(), 0); /// assert_eq!(buf2.len(), 0);
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "collections", #[unstable(feature = "append",
reason = "new API, waiting for dust to settle")] reason = "new API, waiting for dust to settle")]
pub fn append(&mut self, other: &mut Self) { pub fn append(&mut self, other: &mut Self) {
// naive impl // naive impl
@ -1447,7 +1447,7 @@ impl<T: Clone> VecDeque<T> {
/// assert_eq!(a, b); /// assert_eq!(a, b);
/// } /// }
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "deque_extras",
reason = "matches collection reform specification; waiting on panic semantics")] reason = "matches collection reform specification; waiting on panic semantics")]
pub fn resize(&mut self, new_len: usize, value: T) { pub fn resize(&mut self, new_len: usize, value: T) {
let len = self.len(); let len = self.len();
@ -1635,7 +1635,7 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
impl<T> ExactSizeIterator for IntoIter<T> {} impl<T> ExactSizeIterator for IntoIter<T> {}
/// A draining VecDeque iterator /// A draining VecDeque iterator
#[unstable(feature = "collections", #[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle")] reason = "matches collection reform specification, waiting for dust to settle")]
pub struct Drain<'a, T: 'a> { pub struct Drain<'a, T: 'a> {
inner: &'a mut VecDeque<T>, inner: &'a mut VecDeque<T>,

View File

@ -12,6 +12,8 @@
//! are O(highest integer key). //! are O(highest integer key).
#![allow(missing_docs)] #![allow(missing_docs)]
#![unstable(feature = "vecmap",
reason = "may not be stabilized in the standard library")]
use self::Entry::*; use self::Entry::*;
@ -325,7 +327,7 @@ impl<V> VecMap<V> {
/// assert_eq!(a[3], "c"); /// assert_eq!(a[3], "c");
/// assert_eq!(a[4], "d"); /// assert_eq!(a[4], "d");
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "append",
reason = "recently added as part of collections reform 2")] reason = "recently added as part of collections reform 2")]
pub fn append(&mut self, other: &mut Self) { pub fn append(&mut self, other: &mut Self) {
self.extend(other.drain()); self.extend(other.drain());
@ -358,7 +360,7 @@ impl<V> VecMap<V> {
/// assert_eq!(b[3], "c"); /// assert_eq!(b[3], "c");
/// assert_eq!(b[4], "d"); /// assert_eq!(b[4], "d");
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "split_off",
reason = "recently added as part of collections reform 2")] reason = "recently added as part of collections reform 2")]
pub fn split_off(&mut self, at: usize) -> Self { pub fn split_off(&mut self, at: usize) -> Self {
let mut other = VecMap::new(); let mut other = VecMap::new();
@ -410,7 +412,7 @@ impl<V> VecMap<V> {
/// ///
/// assert_eq!(vec, [(1, "a"), (2, "b"), (3, "c")]); /// assert_eq!(vec, [(1, "a"), (2, "b"), (3, "c")]);
/// ``` /// ```
#[unstable(feature = "collections", #[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle")] reason = "matches collection reform specification, waiting for dust to settle")]
pub fn drain<'a>(&'a mut self) -> Drain<'a, V> { pub fn drain<'a>(&'a mut self) -> Drain<'a, V> {
fn filter<A>((i, v): (usize, Option<A>)) -> Option<(usize, A)> { fn filter<A>((i, v): (usize, Option<A>)) -> Option<(usize, A)> {
@ -632,7 +634,7 @@ impl<V> VecMap<V> {
impl<'a, V> Entry<'a, V> { impl<'a, V> Entry<'a, V> {
#[unstable(feature = "collections", #[unstable(feature = "entry",
reason = "will soon be replaced by or_insert")] reason = "will soon be replaced by or_insert")]
#[deprecated(since = "1.0", #[deprecated(since = "1.0",
reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")] reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")]
@ -644,7 +646,7 @@ impl<'a, V> Entry<'a, V> {
} }
} }
#[unstable(feature = "collections", #[unstable(feature = "entry",
reason = "matches entry v3 specification, waiting for dust to settle")] reason = "matches entry v3 specification, waiting for dust to settle")]
/// Ensures a value is in the entry by inserting the default if empty, and returns /// Ensures a value is in the entry by inserting the default if empty, and returns
/// a mutable reference to the value in the entry. /// a mutable reference to the value in the entry.
@ -655,7 +657,7 @@ impl<'a, V> Entry<'a, V> {
} }
} }
#[unstable(feature = "collections", #[unstable(feature = "entry",
reason = "matches entry v3 specification, waiting for dust to settle")] reason = "matches entry v3 specification, waiting for dust to settle")]
/// Ensures a value is in the entry by inserting the result of the default function if empty, /// Ensures a value is in the entry by inserting the result of the default function if empty,
/// and returns a mutable reference to the value in the entry. /// and returns a mutable reference to the value in the entry.
@ -1003,14 +1005,14 @@ pub struct IntoIter<V> {
fn((usize, Option<V>)) -> Option<(usize, V)>> fn((usize, Option<V>)) -> Option<(usize, V)>>
} }
#[unstable(feature = "collections")] #[unstable(feature = "drain")]
pub struct Drain<'a, V:'a> { pub struct Drain<'a, V:'a> {
iter: FilterMap< iter: FilterMap<
Enumerate<vec::Drain<'a, Option<V>>>, Enumerate<vec::Drain<'a, Option<V>>>,
fn((usize, Option<V>)) -> Option<(usize, V)>> fn((usize, Option<V>)) -> Option<(usize, V)>>
} }
#[unstable(feature = "collections")] #[unstable(feature = "drain")]
impl<'a, V> Iterator for Drain<'a, V> { impl<'a, V> Iterator for Drain<'a, V> {
type Item = (usize, V); type Item = (usize, V);
@ -1018,7 +1020,7 @@ impl<'a, V> Iterator for Drain<'a, V> {
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() } fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
} }
#[unstable(feature = "collections")] #[unstable(feature = "drain")]
impl<'a, V> DoubleEndedIterator for Drain<'a, V> { impl<'a, V> DoubleEndedIterator for Drain<'a, V> {
fn next_back(&mut self) -> Option<(usize, V)> { self.iter.next_back() } fn next_back(&mut self) -> Option<(usize, V)> { self.iter.next_back() }
} }

View File

@ -281,8 +281,9 @@
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")] html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(collections)]
#![feature(into_cow)] #![feature(into_cow)]
#![feature(str_escape)]
use self::LabelText::*; use self::LabelText::*;

View File

@ -25,18 +25,22 @@
html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")] html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(append)]
#![feature(associated_consts)] #![feature(associated_consts)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(clone_from_slice)]
#![feature(collections)] #![feature(collections)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(duration)] #![feature(duration)]
#![feature(duration_span)] #![feature(duration_span)]
#![feature(enumset)]
#![feature(fs_canonicalize)] #![feature(fs_canonicalize)]
#![feature(hash_default)] #![feature(hash_default)]
#![feature(into_cow)] #![feature(into_cow)]
#![feature(iter_sum)] #![feature(iter_sum)]
#![feature(libc)] #![feature(libc)]
#![feature(map_in_place)]
#![feature(num_bits_bytes)] #![feature(num_bits_bytes)]
#![feature(path_ext)] #![feature(path_ext)]
#![feature(quote)] #![feature(quote)]
@ -45,10 +49,14 @@
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(slice_bytes)] #![feature(slice_bytes)]
#![feature(slice_extras)]
#![feature(slice_patterns)] #![feature(slice_patterns)]
#![feature(slice_position_elem)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(std_misc)] #![feature(std_misc)]
#![feature(str_char)] #![feature(str_char)]
#![feature(str_matches)]
#![feature(vec_push_all)]
#![feature(wrapping)] #![feature(wrapping)]
#![cfg_attr(test, feature(test))] #![cfg_attr(test, feature(test))]

View File

@ -33,7 +33,6 @@
html_root_url = "http://doc.rust-lang.org/nightly/")] html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(collections)]
#![feature(fs_canonicalize)] #![feature(fs_canonicalize)]
#![feature(libc)] #![feature(libc)]
#![feature(path_ext)] #![feature(path_ext)]
@ -42,6 +41,7 @@
#![feature(slice_bytes)] #![feature(slice_bytes)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(step_by)] #![feature(step_by)]
#![feature(vec_push_all)]
#![cfg_attr(test, feature(test, rand))] #![cfg_attr(test, feature(test, rand))]
extern crate syntax; extern crate syntax;

View File

@ -26,14 +26,15 @@
html_root_url = "http://doc.rust-lang.org/nightly/")] html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(collections)] #![feature(exit_status)]
#![feature(libc)] #![feature(libc)]
#![feature(quote)] #![feature(quote)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(staged_api)]
#![feature(exit_status)]
#![feature(set_stdio)] #![feature(set_stdio)]
#![feature(staged_api)]
#![feature(str_casing)]
#![feature(vec_push_all)]
extern crate arena; extern crate arena;
extern crate flate; extern crate flate;

View File

@ -30,17 +30,17 @@
html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")] html_root_url = "http://doc.rust-lang.org/nightly/")]
#![cfg_attr(test, feature(test))]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(collections)]
#![feature(num_bits_bytes)] #![feature(num_bits_bytes)]
#![feature(quote)] #![feature(quote)]
#![feature(ref_slice)] #![feature(ref_slice)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(str_casing)]
#![feature(str_char)] #![feature(str_char)]
#![cfg_attr(test, feature(test))]
extern crate syntax; extern crate syntax;
#[macro_use] #[macro_use]

View File

@ -27,10 +27,10 @@
#![feature(associated_consts)] #![feature(associated_consts)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(collections)]
#![feature(libc)] #![feature(libc)]
#![feature(link_args)] #![feature(link_args)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(vec_push_all)]
extern crate libc; extern crate libc;
#[macro_use] #[no_link] extern crate rustc_bitflags; #[macro_use] #[no_link] extern crate rustc_bitflags;

View File

@ -20,10 +20,10 @@
html_root_url = "http://doc.rust-lang.org/nightly/")] html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(associated_consts)] #![feature(associated_consts)]
#![feature(collections)]
#![feature(rc_weak)] #![feature(rc_weak)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(slice_extras)]
#![feature(staged_api)] #![feature(staged_api)]
#[macro_use] extern crate log; #[macro_use] extern crate log;

View File

@ -27,7 +27,6 @@
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(collections)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(fs)] #![feature(fs)]
#![feature(iter_cmp)] #![feature(iter_cmp)]
@ -46,6 +45,7 @@
#![feature(std_misc)] #![feature(std_misc)]
#![feature(unicode)] #![feature(unicode)]
#![feature(unicode)] #![feature(unicode)]
#![feature(vec_push_all)]
#![allow(trivial_casts)] #![allow(trivial_casts)]

View File

@ -77,14 +77,16 @@ This API is completely unstable and subject to change.
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(collections, collections_drain)] #![feature(drain)]
#![feature(iter_cmp)] #![feature(iter_cmp)]
#![feature(iter_sum)] #![feature(iter_sum)]
#![feature(quote)] #![feature(quote)]
#![feature(ref_slice)] #![feature(ref_slice)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(slice_extras)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(vec_push_all)]
#[macro_use] extern crate log; #[macro_use] extern crate log;
#[macro_use] extern crate syntax; #[macro_use] extern crate syntax;

View File

@ -310,7 +310,9 @@ impl char {
#[unstable(feature = "unicode", #[unstable(feature = "unicode",
reason = "pending decision about Iterator/Writer/Reader")] reason = "pending decision about Iterator/Writer/Reader")]
#[inline] #[inline]
pub fn encode_utf8(self, dst: &mut [u8]) -> Option<usize> { C::encode_utf8(self, dst) } pub fn encode_utf8(self, dst: &mut [u8]) -> Option<usize> {
C::encode_utf8(self, dst)
}
/// Encodes this character as UTF-16 into the provided `u16` buffer, and /// Encodes this character as UTF-16 into the provided `u16` buffer, and
/// then returns the number of `u16`s written. /// then returns the number of `u16`s written.
@ -345,7 +347,9 @@ impl char {
#[unstable(feature = "unicode", #[unstable(feature = "unicode",
reason = "pending decision about Iterator/Writer/Reader")] reason = "pending decision about Iterator/Writer/Reader")]
#[inline] #[inline]
pub fn encode_utf16(self, dst: &mut [u16]) -> Option<usize> { C::encode_utf16(self, dst) } pub fn encode_utf16(self, dst: &mut [u16]) -> Option<usize> {
C::encode_utf16(self, dst)
}
/// Returns whether the specified character is considered a Unicode /// Returns whether the specified character is considered a Unicode
/// alphabetic code point. /// alphabetic code point.
@ -541,5 +545,7 @@ impl char {
#[unstable(feature = "unicode", #[unstable(feature = "unicode",
reason = "needs expert opinion. is_cjk flag stands out as ugly")] reason = "needs expert opinion. is_cjk flag stands out as ugly")]
#[inline] #[inline]
pub fn width(self, is_cjk: bool) -> Option<usize> { charwidth::width(self, is_cjk) } pub fn width(self, is_cjk: bool) -> Option<usize> {
charwidth::width(self, is_cjk)
}
} }

View File

@ -36,6 +36,8 @@ Core encoding and decoding interfaces.
#![feature(std_misc)] #![feature(std_misc)]
#![feature(str_char)] #![feature(str_char)]
#![feature(unicode)] #![feature(unicode)]
#![feature(vecmap)]
#![feature(enumset)]
#![cfg_attr(test, feature(test))] #![cfg_attr(test, feature(test))]
// test harness access // test harness access

View File

@ -110,7 +110,9 @@
#![feature(box_raw)] #![feature(box_raw)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(char_internals)] #![feature(char_internals)]
#![feature(clone_from_slice)]
#![feature(collections)] #![feature(collections)]
#![feature(collections_bound)]
#![feature(const_fn)] #![feature(const_fn)]
#![feature(core)] #![feature(core)]
#![feature(core_float)] #![feature(core_float)]
@ -126,6 +128,8 @@
#![feature(libc)] #![feature(libc)]
#![feature(linkage, thread_local, asm)] #![feature(linkage, thread_local, asm)]
#![feature(macro_reexport)] #![feature(macro_reexport)]
#![feature(slice_concat_ext)]
#![feature(slice_position_elem)]
#![feature(no_std)] #![feature(no_std)]
#![feature(num_bits_bytes)] #![feature(num_bits_bytes)]
#![feature(oom)] #![feature(oom)]
@ -142,6 +146,7 @@
#![feature(unicode)] #![feature(unicode)]
#![feature(unique)] #![feature(unique)]
#![feature(unsafe_no_drop_flag, filling_drop)] #![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(vec_push_all)]
#![feature(wrapping)] #![feature(wrapping)]
#![feature(zero_one)] #![feature(zero_one)]
#![cfg_attr(test, feature(float_from_str_radix))] #![cfg_attr(test, feature(float_from_str_radix))]

View File

@ -26,15 +26,17 @@
html_root_url = "http://doc.rust-lang.org/nightly/")] html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(associated_consts)] #![feature(associated_consts)]
#![feature(collections)] #![feature(bitset)]
#![feature(collections_drain)] #![feature(drain)]
#![feature(filling_drop)] #![feature(filling_drop)]
#![feature(libc)] #![feature(libc)]
#![feature(ref_slice)] #![feature(ref_slice)]
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(str_char)] #![feature(str_char)]
#![feature(str_escape)]
#![feature(unicode)] #![feature(unicode)]
#![feature(vec_push_all)]
extern crate fmt_macros; extern crate fmt_macros;
extern crate serialize; extern crate serialize;

View File

@ -56,12 +56,12 @@
#![deny(missing_docs)] #![deny(missing_docs)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(collections)] #![feature(path_ext)]
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(std_misc)] #![feature(std_misc)]
#![feature(str_char)] #![feature(str_char)]
#![feature(path_ext)] #![feature(vec_push_all)]
#![cfg_attr(windows, feature(libc))] #![cfg_attr(windows, feature(libc))]
#[macro_use] extern crate log; #[macro_use] extern crate log;

View File

@ -36,7 +36,6 @@
#![feature(asm)] #![feature(asm)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(collections)]
#![feature(duration)] #![feature(duration)]
#![feature(duration_span)] #![feature(duration_span)]
#![feature(fnbox)] #![feature(fnbox)]
@ -44,6 +43,7 @@
#![feature(libc)] #![feature(libc)]
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(set_stdio)] #![feature(set_stdio)]
#![feature(slice_extras)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(std_misc)] #![feature(std_misc)]

View File

@ -10,11 +10,11 @@
#![deny(warnings)] #![deny(warnings)]
#![feature(core)]
#![feature(exit_status)] #![feature(exit_status)]
#![feature(rustdoc)] #![feature(iter_sum)]
#![feature(rustc_private)]
#![feature(path_relative_from)] #![feature(path_relative_from)]
#![feature(rustc_private)]
#![feature(rustdoc)]
extern crate rustdoc; extern crate rustdoc;
extern crate rustc_back; extern crate rustc_back;