Auto merge of #26192 - alexcrichton:features-clean, r=aturon

This commit shards the all-encompassing `core`, `std_misc`, `collections`, and `alloc` features into finer-grained components that are much more easily opted into and tracked. This reflects the effort to push forward current unstable APIs to either stabilization or removal. Keeping track of unstable features on a much more fine-grained basis will enable the library subteam to quickly analyze a feature and help prioritize internally about what APIs should be stabilized.

A few assorted APIs were deprecated along the way, but otherwise this change is just changing the feature name associated with each API. Soon we will have a dashboard for keeping track of all the unstable APIs in the standard library, and I'll also start making issues for each unstable API after performing a first-pass for stabilization.
This commit is contained in:
bors 2015-06-18 19:14:52 +00:00
commit 9cc0b22475
199 changed files with 1391 additions and 1097 deletions

View File

@ -11,13 +11,14 @@
#![crate_type = "bin"]
#![feature(box_syntax)]
#![feature(collections)]
#![feature(rustc_private)]
#![feature(std_misc)]
#![feature(test)]
#![feature(path_ext)]
#![feature(str_char)]
#![feature(dynamic_lib)]
#![feature(libc)]
#![feature(path_ext)]
#![feature(rustc_private)]
#![feature(slice_extras)]
#![feature(str_char)]
#![feature(test)]
#![feature(vec_push_all)]
#![deny(warnings)]

View File

@ -134,7 +134,7 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Arc<U>> for Arc<T> {}
/// Weak pointers will not keep the data inside of the `Arc` alive, and can be
/// used to break cycles between `Arc` pointers.
#[unsafe_no_drop_flag]
#[unstable(feature = "alloc",
#[unstable(feature = "arc_weak",
reason = "Weak pointers may not belong in this module.")]
pub struct Weak<T: ?Sized> {
// FIXME #12808: strange name to try to avoid interfering with
@ -191,23 +191,35 @@ impl<T: ?Sized> Arc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(arc_weak)]
/// use std::sync::Arc;
///
/// let five = Arc::new(5);
///
/// let weak_five = five.downgrade();
/// ```
#[unstable(feature = "alloc",
#[unstable(feature = "arc_weak",
reason = "Weak pointers may not belong in this module.")]
pub fn downgrade(&self) -> Weak<T> {
// See the clone() impl for why this is relaxed
self.inner().weak.fetch_add(1, Relaxed);
Weak { _ptr: self._ptr }
}
}
impl<T: ?Sized> Arc<T> {
/// Get the number of weak references to this value.
#[inline]
#[unstable(feature = "arc_counts")]
pub fn weak_count(this: &Arc<T>) -> usize {
this.inner().weak.load(SeqCst) - 1
}
/// Get the number of strong references to this value.
#[inline]
#[unstable(feature = "arc_counts")]
pub fn strong_count(this: &Arc<T>) -> usize {
this.inner().strong.load(SeqCst)
}
#[inline]
fn inner(&self) -> &ArcInner<T> {
// This unsafety is ok because while this arc is alive we're guaranteed
@ -236,13 +248,15 @@ impl<T: ?Sized> Arc<T> {
/// Get the number of weak references to this value.
#[inline]
#[unstable(feature = "alloc")]
pub fn weak_count<T: ?Sized>(this: &Arc<T>) -> usize { this.inner().weak.load(SeqCst) - 1 }
#[unstable(feature = "arc_counts")]
#[deprecated(since = "1.2.0", reason = "renamed to Arc::weak_count")]
pub fn weak_count<T: ?Sized>(this: &Arc<T>) -> usize { Arc::weak_count(this) }
/// Get the number of strong references to this value.
#[inline]
#[unstable(feature = "alloc")]
pub fn strong_count<T: ?Sized>(this: &Arc<T>) -> usize { this.inner().strong.load(SeqCst) }
#[unstable(feature = "arc_counts")]
#[deprecated(since = "1.2.0", reason = "renamed to Arc::strong_count")]
pub fn strong_count<T: ?Sized>(this: &Arc<T>) -> usize { Arc::strong_count(this) }
/// Returns a mutable reference to the contained value if the `Arc<T>` is unique.
@ -255,7 +269,7 @@ pub fn strong_count<T: ?Sized>(this: &Arc<T>) -> usize { this.inner().strong.loa
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(arc_unique, alloc)]
/// extern crate alloc;
/// # fn main() {
/// use alloc::arc::{Arc, get_mut};
@ -271,10 +285,12 @@ pub fn strong_count<T: ?Sized>(this: &Arc<T>) -> usize { this.inner().strong.loa
/// # }
/// ```
#[inline]
#[unstable(feature = "alloc")]
#[unstable(feature = "arc_unique")]
#[deprecated(since = "1.2.0",
reason = "this function is unsafe with weak pointers")]
pub unsafe fn get_mut<T: ?Sized>(this: &mut Arc<T>) -> Option<&mut T> {
// FIXME(#24880) potential race with upgraded weak pointers here
if strong_count(this) == 1 && weak_count(this) == 0 {
if Arc::strong_count(this) == 1 && Arc::weak_count(this) == 0 {
// This unsafety is ok because we're guaranteed that the pointer
// returned is the *only* pointer that will ever be returned to T. Our
// reference count is guaranteed to be 1 at this point, and we required
@ -342,7 +358,7 @@ impl<T: Clone> Arc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(arc_unique)]
/// use std::sync::Arc;
///
/// # unsafe {
@ -352,7 +368,9 @@ impl<T: Clone> Arc<T> {
/// # }
/// ```
#[inline]
#[unstable(feature = "alloc")]
#[unstable(feature = "arc_unique")]
#[deprecated(since = "1.2.0",
reason = "this function is unsafe with weak pointers")]
pub unsafe fn make_unique(&mut self) -> &mut T {
// FIXME(#24880) potential race with upgraded weak pointers here
//
@ -438,7 +456,7 @@ impl<T: ?Sized> Drop for Arc<T> {
}
}
#[unstable(feature = "alloc",
#[unstable(feature = "arc_weak",
reason = "Weak pointers may not belong in this module.")]
impl<T: ?Sized> Weak<T> {
/// Upgrades a weak reference to a strong reference.
@ -451,7 +469,7 @@ impl<T: ?Sized> Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(arc_weak)]
/// use std::sync::Arc;
///
/// let five = Arc::new(5);
@ -479,7 +497,7 @@ impl<T: ?Sized> Weak<T> {
}
}
#[unstable(feature = "alloc",
#[unstable(feature = "arc_weak",
reason = "Weak pointers may not belong in this module.")]
impl<T: ?Sized> Clone for Weak<T> {
/// Makes a clone of the `Weak<T>`.
@ -489,7 +507,7 @@ impl<T: ?Sized> Clone for Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(arc_weak)]
/// use std::sync::Arc;
///
/// let weak_five = Arc::new(5).downgrade();
@ -513,7 +531,7 @@ impl<T: ?Sized> Drop for Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(arc_weak)]
/// use std::sync::Arc;
///
/// {

View File

@ -10,9 +10,9 @@
//! A pointer type for heap allocation.
//!
//! `Box<T>`, casually referred to as a 'box', provides the simplest form of heap allocation in
//! Rust. Boxes provide ownership for this allocation, and drop their contents when they go out of
//! scope.
//! `Box<T>`, casually referred to as a 'box', provides the simplest form of
//! heap allocation in Rust. Boxes provide ownership for this allocation, and
//! drop their contents when they go out of scope.
//!
//! # Examples
//!
@ -39,15 +39,17 @@
//!
//! This will print `Cons(1, Cons(2, Nil))`.
//!
//! Recursive structures must be boxed, because if the definition of `Cons` looked like this:
//! Recursive structures must be boxed, because if the definition of `Cons`
//! looked like this:
//!
//! ```rust,ignore
//! Cons(T, List<T>),
//! ```
//!
//! It wouldn't work. This is because the size of a `List` depends on how many elements are in the
//! list, and so we don't know how much memory to allocate for a `Cons`. By introducing a `Box`,
//! which has a defined size, we know how big `Cons` needs to be.
//! It wouldn't work. This is because the size of a `List` depends on how many
//! elements are in the list, and so we don't know how much memory to allocate
//! for a `Cons`. By introducing a `Box`, which has a defined size, we know how
//! big `Cons` needs to be.
#![stable(feature = "rust1", since = "1.0.0")]
@ -69,7 +71,7 @@ use core::raw::{TraitObject};
/// The following two examples are equivalent:
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(box_heap)]
/// #![feature(box_syntax)]
/// use std::boxed::HEAP;
///
@ -79,7 +81,7 @@ use core::raw::{TraitObject};
/// }
/// ```
#[lang = "exchange_heap"]
#[unstable(feature = "alloc",
#[unstable(feature = "box_heap",
reason = "may be renamed; uncertain about custom allocator design")]
pub const HEAP: () = ();
@ -119,12 +121,37 @@ impl<T : ?Sized> Box<T> {
/// Function is unsafe, because improper use of this function may
/// lead to memory problems like double-free, for example if the
/// function is called twice on the same raw pointer.
#[unstable(feature = "alloc",
#[unstable(feature = "box_raw",
reason = "may be renamed or moved out of Box scope")]
#[inline]
// NB: may want to be called from_ptr, see comments on CStr::from_ptr
pub unsafe fn from_raw(raw: *mut T) -> Self {
mem::transmute(raw)
}
/// Consumes the `Box`, returning the wrapped raw pointer.
///
/// After call to this function, caller is responsible for the memory
/// previously managed by `Box`, in particular caller should properly
/// destroy `T` and release memory. The proper way to do it is to
/// convert pointer back to `Box` with `Box::from_raw` function, because
/// `Box` does not specify, how memory is allocated.
///
/// # Examples
/// ```
/// # #![feature(box_raw)]
/// use std::boxed;
///
/// let seventeen = Box::new(17u32);
/// let raw = boxed::into_raw(seventeen);
/// let boxed_again = unsafe { Box::from_raw(raw) };
/// ```
#[unstable(feature = "box_raw", reason = "may be renamed")]
#[inline]
// NB: may want to be called into_ptr, see comments on CStr::from_ptr
pub fn into_raw(b: Box<T>) -> *mut T {
unsafe { mem::transmute(b) }
}
}
/// Consumes the `Box`, returning the wrapped raw pointer.
@ -137,18 +164,18 @@ impl<T : ?Sized> Box<T> {
///
/// # Examples
/// ```
/// # #![feature(alloc)]
/// # #![feature(box_raw)]
/// use std::boxed;
///
/// let seventeen = Box::new(17u32);
/// let raw = boxed::into_raw(seventeen);
/// let boxed_again = unsafe { Box::from_raw(raw) };
/// ```
#[unstable(feature = "alloc",
reason = "may be renamed")]
#[unstable(feature = "box_raw", reason = "may be renamed")]
#[deprecated(since = "1.2.0", reason = "renamed to Box::into_raw")]
#[inline]
pub fn into_raw<T : ?Sized>(b: Box<T>) -> *mut T {
unsafe { mem::transmute(b) }
Box::into_raw(b)
}
#[stable(feature = "rust1", since = "1.0.0")]
@ -181,7 +208,7 @@ impl<T: Clone> Clone for Box<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc, core)]
/// # #![feature(box_raw)]
/// let x = Box::new(5);
/// let mut y = Box::new(10);
///
@ -242,7 +269,7 @@ impl Box<Any> {
if self.is::<T>() {
unsafe {
// Get the raw representation of the trait object
let raw = into_raw(self);
let raw = Box::into_raw(self);
let to: TraitObject =
mem::transmute::<*mut Any, TraitObject>(raw);
@ -334,7 +361,7 @@ impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {}
/// -> i32>`.
///
/// ```
/// #![feature(core)]
/// #![feature(fnbox)]
///
/// use std::boxed::FnBox;
/// use std::collections::HashMap;
@ -355,7 +382,7 @@ impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {}
/// }
/// ```
#[rustc_paren_sugar]
#[unstable(feature = "core", reason = "Newly introduced")]
#[unstable(feature = "fnbox", reason = "Newly introduced")]
pub trait FnBox<A> {
type Output;

View File

@ -8,6 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![unstable(feature = "heap_api",
reason = "the precise API and guarantees it provides may be tweaked \
slightly, especially to possibly take into account the \
types being stored to make room for a future \
tracing garbage collector")]
use core::{isize, usize};
#[inline(always)]
@ -94,7 +100,6 @@ pub fn usable_size(size: usize, align: usize) -> usize {
///
/// These statistics may be inconsistent if other threads use the allocator
/// during the call.
#[unstable(feature = "alloc")]
pub fn stats_print() {
imp::stats_print();
}

View File

@ -59,32 +59,40 @@
// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)
#![cfg_attr(stage0, feature(custom_attribute))]
#![crate_name = "alloc"]
#![unstable(feature = "alloc")]
#![feature(staged_api)]
#![staged_api]
#![crate_type = "rlib"]
#![staged_api]
#![unstable(feature = "alloc",
reason = "this library is unlikely to be stabilized in its current \
form or name")]
#![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_root_url = "http://doc.rust-lang.org/nightly/")]
#![doc(test(no_crate_inject))]
#![feature(no_std)]
html_root_url = "http://doc.rust-lang.org/nightly/",
test(no_crate_inject))]
#![no_std]
#![feature(allocator)]
#![feature(box_syntax)]
#![feature(coerce_unsized)]
#![feature(core)]
#![feature(core_intrinsics)]
#![feature(core_prelude)]
#![feature(custom_attribute)]
#![feature(fundamental)]
#![feature(lang_items)]
#![feature(box_syntax)]
#![feature(no_std)]
#![feature(nonzero)]
#![feature(optin_builtin_traits)]
#![feature(raw)]
#![feature(staged_api)]
#![feature(unboxed_closures)]
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(core)]
#![feature(unique)]
#![cfg_attr(test, feature(test, alloc, rustc_private))]
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(unsize)]
#![cfg_attr(test, feature(test, alloc, rustc_private, box_raw))]
#![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")),
feature(libc))]
#[macro_use]
extern crate core;
@ -118,6 +126,7 @@ pub mod rc;
/// Common out-of-memory routine
#[cold]
#[inline(never)]
#[unstable(feature = "oom", reason = "not a scrutinized interface")]
pub fn oom() -> ! {
// FIXME(#14674): This really needs to do something other than just abort
// here, but any printing done must be *guaranteed* to not
@ -138,4 +147,5 @@ pub fn oom() -> ! {
// to get linked in to libstd successfully (the linker won't
// optimize it out).
#[doc(hidden)]
#[unstable(feature = "issue_14344_fixme")]
pub fn fixme_14344_be_sure_to_link_to_collections() {}

View File

@ -32,7 +32,6 @@
//! and have the `Owner` remain allocated as long as any `Gadget` points at it.
//!
//! ```rust
//! # #![feature(alloc)]
//! use std::rc::Rc;
//!
//! struct Owner {
@ -92,7 +91,7 @@
//! documentation for more details on interior mutability.
//!
//! ```rust
//! # #![feature(alloc)]
//! # #![feature(rc_weak)]
//! use std::rc::Rc;
//! use std::rc::Weak;
//! use std::cell::RefCell;
@ -149,26 +148,24 @@
//! ```
#![stable(feature = "rust1", since = "1.0.0")]
use core::prelude::*;
#[cfg(not(test))]
use boxed;
use boxed::Box;
#[cfg(test)]
use std::boxed;
use std::boxed::Box;
use core::cell::Cell;
use core::clone::Clone;
use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
use core::default::Default;
use core::cmp::Ordering;
use core::fmt;
use core::hash::{Hasher, Hash};
use core::intrinsics::{assume, drop_in_place};
use core::marker::{self, Sized, Unsize};
use core::marker::{self, Unsize};
use core::mem::{self, min_align_of, size_of, min_align_of_val, size_of_val, forget};
use core::nonzero::NonZero;
use core::ops::{CoerceUnsized, Deref, Drop};
use core::option::Option;
use core::option::Option::{Some, None};
use core::ops::{CoerceUnsized, Deref};
use core::ptr;
use core::result::Result;
use core::result::Result::{Ok, Err};
use heap::deallocate;
@ -213,7 +210,7 @@ impl<T> Rc<T> {
// pointers, which ensures that the weak destructor never frees
// the allocation while the strong destructor is running, even
// if the weak pointer is stored inside the strong one.
_ptr: NonZero::new(boxed::into_raw(box RcBox {
_ptr: NonZero::new(Box::into_raw(box RcBox {
strong: Cell::new(1),
weak: Cell::new(1),
value: value
@ -221,6 +218,42 @@ impl<T> Rc<T> {
}
}
}
/// Unwraps the contained value if the `Rc<T>` is unique.
///
/// If the `Rc<T>` is not unique, an `Err` is returned with the same
/// `Rc<T>`.
///
/// # Examples
///
/// ```
/// # #![feature(rc_unique)]
/// use std::rc::Rc;
///
/// let x = Rc::new(3);
/// assert_eq!(Rc::try_unwrap(x), Ok(3));
///
/// let x = Rc::new(4);
/// let _y = x.clone();
/// assert_eq!(Rc::try_unwrap(x), Err(Rc::new(4)));
/// ```
#[inline]
#[unstable(feature = "rc_unique")]
pub fn try_unwrap(rc: Rc<T>) -> Result<T, Rc<T>> {
if Rc::is_unique(&rc) {
unsafe {
let val = ptr::read(&*rc); // copy the contained object
// destruct the box and skip our Drop
// we can ignore the refcounts because we know we're unique
deallocate(*rc._ptr as *mut u8, size_of::<RcBox<T>>(),
min_align_of::<RcBox<T>>());
forget(rc);
Ok(val)
}
} else {
Err(rc)
}
}
}
impl<T: ?Sized> Rc<T> {
@ -229,30 +262,90 @@ impl<T: ?Sized> Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(rc_weak)]
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
///
/// let weak_five = five.downgrade();
/// ```
#[unstable(feature = "alloc",
#[unstable(feature = "rc_weak",
reason = "Weak pointers may not belong in this module")]
pub fn downgrade(&self) -> Weak<T> {
self.inc_weak();
Weak { _ptr: self._ptr }
}
/// Get the number of weak references to this value.
#[inline]
#[unstable(feature = "rc_counts")]
pub fn weak_count(this: &Rc<T>) -> usize { this.weak() - 1 }
/// Get the number of strong references to this value.
#[inline]
#[unstable(feature = "rc_counts")]
pub fn strong_count(this: &Rc<T>) -> usize { this.strong() }
/// Returns true if there are no other `Rc` or `Weak<T>` values that share
/// the same inner value.
///
/// # Examples
///
/// ```
/// # #![feature(rc_unique)]
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
///
/// assert!(Rc::is_unique(&five));
/// ```
#[inline]
#[unstable(feature = "rc_unique")]
pub fn is_unique(rc: &Rc<T>) -> bool {
Rc::weak_count(rc) == 0 && Rc::strong_count(rc) == 1
}
/// Returns a mutable reference to the contained value if the `Rc<T>` is
/// unique.
///
/// Returns `None` if the `Rc<T>` is not unique.
///
/// # Examples
///
/// ```
/// # #![feature(rc_unique)]
/// use std::rc::Rc;
///
/// let mut x = Rc::new(3);
/// *Rc::get_mut(&mut x).unwrap() = 4;
/// assert_eq!(*x, 4);
///
/// let _y = x.clone();
/// assert!(Rc::get_mut(&mut x).is_none());
/// ```
#[inline]
#[unstable(feature = "rc_unique")]
pub fn get_mut(rc: &mut Rc<T>) -> Option<&mut T> {
if Rc::is_unique(rc) {
let inner = unsafe { &mut **rc._ptr };
Some(&mut inner.value)
} else {
None
}
}
}
/// Get the number of weak references to this value.
#[inline]
#[unstable(feature = "alloc")]
pub fn weak_count<T: ?Sized>(this: &Rc<T>) -> usize { this.weak() - 1 }
#[unstable(feature = "rc_counts")]
#[deprecated(since = "1.2.0", reason = "renamed to Rc::weak_count")]
pub fn weak_count<T: ?Sized>(this: &Rc<T>) -> usize { Rc::weak_count(this) }
/// Get the number of strong references to this value.
#[inline]
#[unstable(feature = "alloc")]
pub fn strong_count<T: ?Sized>(this: &Rc<T>) -> usize { this.strong() }
#[unstable(feature = "rc_counts")]
#[deprecated(since = "1.2.0", reason = "renamed to Rc::strong_count")]
pub fn strong_count<T: ?Sized>(this: &Rc<T>) -> usize { Rc::strong_count(this) }
/// Returns true if there are no other `Rc` or `Weak<T>` values that share the
/// same inner value.
@ -260,7 +353,7 @@ pub fn strong_count<T: ?Sized>(this: &Rc<T>) -> usize { this.strong() }
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(rc_unique)]
/// use std::rc;
/// use std::rc::Rc;
///
@ -269,10 +362,9 @@ pub fn strong_count<T: ?Sized>(this: &Rc<T>) -> usize { this.strong() }
/// rc::is_unique(&five);
/// ```
#[inline]
#[unstable(feature = "alloc")]
pub fn is_unique<T>(rc: &Rc<T>) -> bool {
weak_count(rc) == 0 && strong_count(rc) == 1
}
#[unstable(feature = "rc_unique")]
#[deprecated(since = "1.2.0", reason = "renamed to Rc::is_unique")]
pub fn is_unique<T>(rc: &Rc<T>) -> bool { Rc::is_unique(rc) }
/// Unwraps the contained value if the `Rc<T>` is unique.
///
@ -281,7 +373,7 @@ pub fn is_unique<T>(rc: &Rc<T>) -> bool {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(rc_unique)]
/// use std::rc::{self, Rc};
///
/// let x = Rc::new(3);
@ -292,22 +384,9 @@ pub fn is_unique<T>(rc: &Rc<T>) -> bool {
/// assert_eq!(rc::try_unwrap(x), Err(Rc::new(4)));
/// ```
#[inline]
#[unstable(feature = "alloc")]
pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> {
if is_unique(&rc) {
unsafe {
let val = ptr::read(&*rc); // copy the contained object
// destruct the box and skip our Drop
// we can ignore the refcounts because we know we're unique
deallocate(*rc._ptr as *mut u8, size_of::<RcBox<T>>(),
min_align_of::<RcBox<T>>());
forget(rc);
Ok(val)
}
} else {
Err(rc)
}
}
#[unstable(feature = "rc_unique")]
#[deprecated(since = "1.2.0", reason = "renamed to Rc::try_unwrap")]
pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> { Rc::try_unwrap(rc) }
/// Returns a mutable reference to the contained value if the `Rc<T>` is unique.
///
@ -316,7 +395,7 @@ pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(rc_unique)]
/// use std::rc::{self, Rc};
///
/// let mut x = Rc::new(3);
@ -327,15 +406,9 @@ pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> {
/// assert!(rc::get_mut(&mut x).is_none());
/// ```
#[inline]
#[unstable(feature = "alloc")]
pub fn get_mut<T>(rc: &mut Rc<T>) -> Option<&mut T> {
if is_unique(rc) {
let inner = unsafe { &mut **rc._ptr };
Some(&mut inner.value)
} else {
None
}
}
#[unstable(feature = "rc_unique")]
#[deprecated(since = "1.2.0", reason = "renamed to Rc::get_mut")]
pub fn get_mut<T>(rc: &mut Rc<T>) -> Option<&mut T> { Rc::get_mut(rc) }
impl<T: Clone> Rc<T> {
/// Make a mutable reference from the given `Rc<T>`.
@ -346,7 +419,7 @@ impl<T: Clone> Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(rc_unique)]
/// use std::rc::Rc;
///
/// let mut five = Rc::new(5);
@ -354,9 +427,9 @@ impl<T: Clone> Rc<T> {
/// let mut_five = five.make_unique();
/// ```
#[inline]
#[unstable(feature = "alloc")]
#[unstable(feature = "rc_unique")]
pub fn make_unique(&mut self) -> &mut T {
if !is_unique(self) {
if !Rc::is_unique(self) {
*self = Rc::new((**self).clone())
}
// This unsafety is ok because we're guaranteed that the pointer
@ -390,7 +463,6 @@ impl<T: ?Sized> Drop for Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::rc::Rc;
///
/// {
@ -443,7 +515,6 @@ impl<T: ?Sized> Clone for Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
@ -652,7 +723,7 @@ impl<T> fmt::Pointer for Rc<T> {
///
/// See the [module level documentation](./index.html) for more.
#[unsafe_no_drop_flag]
#[unstable(feature = "alloc",
#[unstable(feature = "rc_weak",
reason = "Weak pointers may not belong in this module.")]
pub struct Weak<T: ?Sized> {
// FIXME #12808: strange names to try to avoid interfering with
@ -663,7 +734,7 @@ pub struct Weak<T: ?Sized> {
impl<T: ?Sized> !marker::Send for Weak<T> {}
impl<T: ?Sized> !marker::Sync for Weak<T> {}
#[unstable(feature = "alloc",
#[unstable(feature = "rc_weak",
reason = "Weak pointers may not belong in this module.")]
impl<T: ?Sized> Weak<T> {
@ -677,7 +748,7 @@ impl<T: ?Sized> Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(rc_weak)]
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
@ -705,7 +776,7 @@ impl<T: ?Sized> Drop for Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(rc_weak)]
/// use std::rc::Rc;
///
/// {
@ -741,7 +812,7 @@ impl<T: ?Sized> Drop for Weak<T> {
}
}
#[unstable(feature = "alloc",
#[unstable(feature = "rc_weak",
reason = "Weak pointers may not belong in this module.")]
impl<T: ?Sized> Clone for Weak<T> {
@ -752,7 +823,7 @@ impl<T: ?Sized> Clone for Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// # #![feature(rc_weak)]
/// use std::rc::Rc;
///
/// let weak_five = Rc::new(5).downgrade();

View File

@ -32,9 +32,12 @@
#![feature(alloc)]
#![feature(box_syntax)]
#![feature(core)]
#![feature(core_intrinsics)]
#![feature(heap_api)]
#![feature(oom)]
#![feature(ptr_as_ref)]
#![feature(raw)]
#![feature(staged_api)]
#![feature(unboxed_closures)]
#![cfg_attr(test, feature(test))]
extern crate alloc;

View File

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

View File

@ -38,7 +38,7 @@
//! [sieve]: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
//!
//! ```
//! # #![feature(collections, core, step_by)]
//! # #![feature(bitset, bitvec, range_inclusive, step_by)]
//! use std::collections::{BitSet, BitVec};
//! use std::iter;
//!
@ -86,6 +86,7 @@ use core::cmp::Ordering;
use core::cmp;
use core::fmt;
use core::hash;
#[allow(deprecated)]
use core::iter::RandomAccessIterator;
use core::iter::{Chain, Enumerate, Repeat, Skip, Take, repeat, Cloned};
use core::iter::{self, FromIterator};
@ -133,7 +134,7 @@ const FALSE: &'static bool = &false;
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(10, false);
@ -156,8 +157,7 @@ const FALSE: &'static bool = &false;
/// println!("{:?}", bv);
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
/// ```
#[unstable(feature = "collections",
reason = "RFC 509")]
#[unstable(feature = "bitvec", reason = "RFC 509")]
pub struct BitVec {
/// Internal representation of the bit vector
storage: Vec<u32>,
@ -181,14 +181,16 @@ impl Index<usize> for BitVec {
/// Computes how many blocks are needed to store that many bits
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
// reserve enough. But if we want exactly a multiple of 32, this will actually allocate
// one too many. So we need to check if that's the case. We can do that by computing if
// bitwise AND by `32 - 1` is 0. But LLVM should be able to optimize the semantically
// superior modulo operator on a power of two to this.
// If we want 17 bits, dividing by 32 will produce 0. So we add 1 to make
// sure we reserve enough. But if we want exactly a multiple of 32, this
// will actually allocate one too many. So we need to check if that's the
// case. We can do that by computing if bitwise AND by `32 - 1` is 0. But
// 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
// `(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 {
bits / u32::BITS
} else {
@ -202,6 +204,7 @@ fn mask_for_bits(bits: usize) -> u32 {
!0 >> (u32::BITS - bits % u32::BITS) % u32::BITS
}
#[unstable(feature = "bitvec", reason = "RFC 509")]
impl BitVec {
/// 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
@ -248,7 +251,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
/// let mut bv = BitVec::new();
/// ```
@ -263,7 +266,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let bv = BitVec::from_elem(10, false);
@ -304,7 +307,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let bv = BitVec::from_bytes(&[0b10100000, 0b00010010]);
@ -347,7 +350,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let bv = BitVec::from_fn(5, |i| { i % 2 == 0 });
@ -366,7 +369,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let bv = BitVec::from_bytes(&[0b01100000]);
@ -399,7 +402,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(5, false);
@ -407,8 +410,6 @@ impl BitVec {
/// assert_eq!(bv[3], true);
/// ```
#[inline]
#[unstable(feature = "collections",
reason = "panic semantics are likely to change in the future")]
pub fn set(&mut self, i: usize, x: bool) {
assert!(i < self.nbits);
let w = i / u32::BITS;
@ -424,7 +425,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let before = 0b01100000;
@ -445,7 +446,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let before = 0b01100000;
@ -474,7 +475,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let a = 0b01100100;
@ -505,7 +506,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let a = 0b01100100;
@ -536,7 +537,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let a = 0b01100100;
@ -566,7 +567,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(5, true);
@ -591,7 +592,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let bv = BitVec::from_bytes(&[0b01110100, 0b10010010]);
@ -608,7 +609,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections, bit_vec_append_split_off)]
/// # #![feature(bitvec, append)]
/// use std::collections::BitVec;
///
/// let mut a = BitVec::from_bytes(&[0b10000000]);
@ -621,7 +622,7 @@ impl BitVec {
/// assert!(a.eq_vec(&[true, false, false, false, false, false, false, false,
/// 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")]
pub fn append(&mut self, other: &mut Self) {
let b = self.len() % u32::BITS;
@ -651,7 +652,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections, bit_vec_append_split_off)]
/// # #![feature(bitvec, split_off)]
/// use std::collections::BitVec;
/// let mut a = BitVec::new();
/// a.push(true);
@ -666,7 +667,7 @@ impl BitVec {
/// assert!(a.eq_vec(&[true, false]));
/// 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")]
pub fn split_off(&mut self, at: usize) -> Self {
assert!(at <= self.len(), "`at` out of bounds");
@ -712,7 +713,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(10, false);
@ -730,7 +731,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(10, false);
@ -752,7 +753,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(3, true);
@ -800,7 +801,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let bv = BitVec::from_bytes(&[0b10100000]);
@ -821,7 +822,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_bytes(&[0b01001011]);
@ -848,7 +849,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(3, false);
@ -879,7 +880,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(3, false);
@ -902,7 +903,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::new();
@ -924,7 +925,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_bytes(&[0b01001011]);
@ -975,7 +976,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_bytes(&[0b01001001]);
@ -1006,7 +1007,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::new();
@ -1188,6 +1189,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> {
impl<'a> ExactSizeIterator for Iter<'a> {}
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl<'a> RandomAccessIterator for Iter<'a> {
#[inline]
fn indexable(&self) -> usize {
@ -1224,7 +1226,7 @@ impl<'a> IntoIterator for &'a BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitvec, bitset)]
/// use std::collections::{BitSet, BitVec};
///
/// // It's a regular set
@ -1254,8 +1256,7 @@ impl<'a> IntoIterator for &'a BitVec {
/// assert!(bv[3]);
/// ```
#[derive(Clone)]
#[unstable(feature = "collections",
reason = "RFC 509")]
#[unstable(feature = "bitset", reason = "RFC 509")]
pub struct BitSet {
bit_vec: BitVec,
}
@ -1322,13 +1323,14 @@ impl cmp::PartialEq for BitSet {
#[stable(feature = "rust1", since = "1.0.0")]
impl cmp::Eq for BitSet {}
#[unstable(feature = "bitset", reason = "RFC 509")]
impl BitSet {
/// Creates a new empty `BitSet`.
///
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::new();
@ -1345,7 +1347,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::with_capacity(100);
@ -1363,7 +1365,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset, bitvec)]
/// use std::collections::{BitVec, BitSet};
///
/// let bv = BitVec::from_bytes(&[0b01100000]);
@ -1385,7 +1387,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::with_capacity(100);
@ -1397,9 +1399,9 @@ impl BitSet {
self.bit_vec.capacity()
}
/// Reserves capacity for the given `BitSet` to contain `len` distinct elements. In the case
/// of `BitSet` this means reallocations will not occur as long as all inserted elements
/// are less than `len`.
/// Reserves capacity for the given `BitSet` to contain `len` distinct
/// elements. In the case of `BitSet` this means reallocations will not
/// occur as long as all inserted elements are less than `len`.
///
/// The collection may reserve more space to avoid frequent reallocations.
///
@ -1407,7 +1409,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::new();
@ -1422,19 +1424,19 @@ impl BitSet {
}
}
/// Reserves the minimum capacity for the given `BitSet` to contain `len` distinct elements.
/// In the case of `BitSet` this means reallocations will not occur as long as all inserted
/// elements are less than `len`.
/// Reserves the minimum capacity for the given `BitSet` to contain `len`
/// distinct elements. In the case of `BitSet` this means reallocations
/// will not occur as long as all inserted elements are less than `len`.
///
/// Note that the allocator may give the collection more space than it requests. Therefore
/// capacity can not be relied upon to be precisely minimal. Prefer `reserve_len` if future
/// insertions are expected.
/// Note that the allocator may give the collection more space than it
/// requests. Therefore capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve_len` if future insertions are expected.
///
///
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::new();
@ -1455,7 +1457,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::new();
@ -1476,7 +1478,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::new();
@ -1523,7 +1525,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::new();
@ -1556,7 +1558,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset, bitvec)]
/// use std::collections::{BitVec, BitSet};
///
/// let s = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01001010]));
@ -1578,7 +1580,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset, bitvec)]
/// use std::collections::{BitVec, BitSet};
///
/// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000]));
@ -1602,12 +1604,13 @@ impl BitSet {
}
/// Iterator over each usize stored in `self` intersect `other`.
/// See [intersect_with](#method.intersect_with) for an efficient in-place version.
/// See [intersect_with](#method.intersect_with) for an efficient in-place
/// version.
///
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset, bitvec)]
/// use std::collections::{BitVec, BitSet};
///
/// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000]));
@ -1632,12 +1635,13 @@ impl BitSet {
}
/// Iterator over each usize stored in the `self` setminus `other`.
/// See [difference_with](#method.difference_with) for an efficient in-place version.
/// See [difference_with](#method.difference_with) for an efficient in-place
/// version.
///
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset, bitvec)]
/// use std::collections::{BitSet, BitVec};
///
/// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000]));
@ -1667,14 +1671,15 @@ impl BitSet {
}))
}
/// Iterator over each usize stored in the symmetric difference of `self` and `other`.
/// See [symmetric_difference_with](#method.symmetric_difference_with) for
/// an efficient in-place version.
/// Iterator over each usize stored in the symmetric difference of `self`
/// and `other`. See
/// [symmetric_difference_with](#method.symmetric_difference_with) for an
/// efficient in-place version.
///
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset, bitvec)]
/// use std::collections::{BitSet, BitVec};
///
/// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000]));
@ -1702,7 +1707,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset, bitvec)]
/// use std::collections::{BitSet, BitVec};
///
/// let a = 0b01101000;
@ -1726,7 +1731,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset, bitvec)]
/// use std::collections::{BitSet, BitVec};
///
/// let a = 0b01101000;
@ -1751,7 +1756,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset, bitvec)]
/// use std::collections::{BitSet, BitVec};
///
/// let a = 0b01101000;
@ -1784,7 +1789,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(bitset, bitvec)]
/// use std::collections::{BitSet, BitVec};
///
/// let a = 0b01101000;
@ -1808,7 +1813,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections, bit_set_append_split_off)]
/// # #![feature(bitset, bitvec, append)]
/// use std::collections::{BitVec, BitSet};
///
/// let mut a = BitSet::new();
@ -1826,7 +1831,7 @@ impl BitSet {
/// assert_eq!(b.len(), 0);
/// 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")]
pub fn append(&mut self, other: &mut Self) {
self.union_with(other);
@ -1839,7 +1844,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections, bit_set_append_split_off)]
/// # #![feature(bitset, bitvec, split_off)]
/// use std::collections::{BitSet, BitVec};
/// let mut a = BitSet::new();
/// a.insert(2);
@ -1854,7 +1859,7 @@ impl BitSet {
/// assert_eq!(a, BitSet::from_bit_vec(BitVec::from_bytes(&[0b01100000])));
/// 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")]
pub fn split_off(&mut self, at: usize) -> Self {
let mut other = BitSet::new();

View File

@ -685,10 +685,7 @@ mod stack {
/// tied to the original tree.
pub fn into_top(mut self) -> &'a mut V {
unsafe {
mem::copy_mut_lifetime(
self.map,
self.top.from_raw_mut().val_mut()
)
&mut *(self.top.from_raw_mut().val_mut() as *mut V)
}
}
}
@ -1151,7 +1148,7 @@ impl<'a, K, V> DoubleEndedIterator for RangeMut<'a, K, V> {
}
impl<'a, K: Ord, V> Entry<'a, K, V> {
#[unstable(feature = "std_misc",
#[unstable(feature = "entry",
reason = "will soon be replaced by or_insert")]
#[deprecated(since = "1.0",
reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")]
@ -1507,7 +1504,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(btree_range, collections_bound)]
/// use std::collections::BTreeMap;
/// use std::collections::Bound::{Included, Unbounded};
///
@ -1520,7 +1517,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// }
/// 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")]
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, [])
@ -1534,7 +1531,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(btree_range, collections_bound)]
/// use std::collections::BTreeMap;
/// use std::collections::Bound::{Included, Excluded};
///
@ -1548,7 +1545,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// println!("{} => {}", name, balance);
/// }
/// ```
#[unstable(feature = "collections",
#[unstable(feature = "btree_range",
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> {
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.
///
/// B cannot be less than 2.
#[unstable(feature = "collections",
#[unstable(feature = "btree_b",
reason = "probably want this to be on the type, eventually")]
pub fn with_b(b: usize) -> BTreeSet<T> {
BTreeSet { map: BTreeMap::with_b(b) }
@ -141,7 +141,7 @@ impl<T: Ord> BTreeSet<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(btree_range, collections_bound)]
/// use std::collections::BTreeSet;
/// use std::collections::Bound::{Included, Unbounded};
///
@ -154,7 +154,7 @@ impl<T: Ord> BTreeSet<T> {
/// }
/// 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")]
pub fn range<'a>(&'a self, min: Bound<&T>, max: Bound<&T>) -> Range<'a, T> {
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
//! 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::marker;
use core::fmt;
use core::iter::{FromIterator};
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.
///
/// It is a logic error for an item to be modified in such a way that the transformation of the
/// item to or from a `usize`, as determined by the `CLike` trait, changes while the item is in the
/// set. This is normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe
/// code.
/// It is a logic error for an item to be modified in such a way that the
/// transformation of the item to or from a `usize`, as determined by the
/// `CLike` trait, changes while the item is in the set. This is normally only
/// possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct EnumSet<E> {
// We must maintain the invariant that no bits are set
// for which no variant exists
@ -93,22 +98,16 @@ fn bit<E:CLike>(e: &E) -> usize {
impl<E:CLike> EnumSet<E> {
/// Returns an empty `EnumSet`.
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn new() -> EnumSet<E> {
EnumSet {bits: 0, marker: marker::PhantomData}
}
/// 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 {
self.bits.count_ones() as usize
}
/// 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 {
self.bits == 0
}
@ -118,22 +117,16 @@ impl<E:CLike> EnumSet<E> {
}
/// 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 {
(self.bits & other.bits) == 0
}
/// 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 {
(self.bits & other.bits) == other.bits
}
/// 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 {
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
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn insert(&mut self, e: E) -> bool {
let result = !self.contains(&e);
self.bits |= bit(&e);
@ -160,8 +151,6 @@ impl<E:CLike> EnumSet<E> {
}
/// 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 {
let result = self.contains(e);
self.bits &= !bit(e);
@ -169,15 +158,11 @@ impl<E:CLike> EnumSet<E> {
}
/// 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 {
(self.bits & bit(e)) != 0
}
/// 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> {
Iter::new(self.bits)
}

View File

@ -172,9 +172,8 @@
//! like:
//!
//! ```
//! # #![feature(core, std_misc)]
//! # #![feature(fmt_flags)]
//! use std::fmt;
//! use std::f64;
//!
//! #[derive(Debug)]
//! struct Vector2D {

View File

@ -10,37 +10,58 @@
//! 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)
#![cfg_attr(stage0, feature(custom_attribute))]
#![crate_name = "collections"]
#![unstable(feature = "collections")]
#![staged_api]
#![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",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![doc(test(no_crate_inject))]
html_playground_url = "http://play.rust-lang.org/",
test(no_crate_inject))]
#![allow(trivial_casts)]
#![cfg_attr(test, allow(deprecated))] // rand
#![feature(alloc)]
#![feature(box_syntax)]
#![feature(box_patterns)]
#![feature(box_raw)]
#![feature(box_syntax)]
#![feature(core)]
#![feature(core_intrinsics)]
#![feature(core_prelude)]
#![feature(core_slice_ext)]
#![feature(core_str_ext)]
#![feature(heap_api)]
#![feature(iter_cmp)]
#![feature(iter_idx)]
#![feature(iter_order)]
#![feature(iter_arith)]
#![feature(iter_arith)]
#![feature(lang_items)]
#![feature(num_bits_bytes)]
#![feature(oom)]
#![feature(pattern)]
#![feature(ptr_as_ref)]
#![feature(raw)]
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(step_by)]
#![feature(str_char)]
#![feature(str_match_indices)]
#![feature(unboxed_closures)]
#![feature(unicode)]
#![feature(unique)]
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(step_by)]
#![feature(str_char)]
#![feature(slice_patterns)]
#![feature(utf8_error)]
#![cfg_attr(test, feature(rand, test))]
#![cfg_attr(test, allow(deprecated))] // rand
#![cfg_attr(not(test), feature(str_words))]
#![feature(no_std)]
@ -88,14 +109,12 @@ pub mod vec;
pub mod vec_deque;
pub mod vec_map;
#[unstable(feature = "collections",
reason = "RFC 509")]
#[unstable(feature = "bitvec", reason = "RFC 509")]
pub mod bit_vec {
pub use bit::{BitVec, Iter};
}
#[unstable(feature = "collections",
reason = "RFC 509")]
#[unstable(feature = "bitset", reason = "RFC 509")]
pub mod bit_set {
pub use bit::{BitSet, Union, Intersection, Difference, SymmetricDifference};
pub use bit::SetIter as Iter;
@ -114,6 +133,7 @@ pub mod btree_set {
// FIXME(#14344) this shouldn't be necessary
#[doc(hidden)]
#[unstable(feature = "issue_14344_fixme")]
pub fn fixme_14344_be_sure_to_link_to_collections() {}
#[cfg(not(test))]
@ -122,6 +142,7 @@ mod std {
}
/// An endpoint of a range of keys.
#[unstable(feature = "collections_bound")]
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub enum Bound<T> {
/// An inclusive bound.

View File

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

View File

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

View File

@ -11,7 +11,8 @@
//! Utilities for slice manipulation
//!
//! 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
@ -69,8 +70,9 @@
//! }
//! ```
//!
//! This iterator yields mutable references to the slice's elements, so while the element
//! type of the slice is `i32`, the element type of the iterator is `&mut i32`.
//! This iterator yields mutable references to the slice's elements, so while
//! 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
//! iterators.
@ -149,6 +151,7 @@ mod hack {
}
}
#[allow(deprecated)]
pub fn permutations<T>(s: &[T]) -> Permutations<T> where T: Clone {
Permutations{
swaps: ElementSwaps::new(s.len()),
@ -278,14 +281,14 @@ impl<T> [T] {
}
/// 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]
pub fn tail(&self) -> &[T] {
core_slice::SliceExt::tail(self)
}
/// Returns all but the first element of a mutable slice
#[unstable(feature = "collections",
#[unstable(feature = "slice_extras",
reason = "likely to be renamed or removed")]
#[inline]
pub fn tail_mut(&mut self) -> &mut [T] {
@ -293,14 +296,14 @@ impl<T> [T] {
}
/// 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]
pub fn init(&self) -> &[T] {
core_slice::SliceExt::init(self)
}
/// Returns all but the last element of a mutable slice
#[unstable(feature = "collections",
#[unstable(feature = "slice_extras",
reason = "likely to be renamed or removed")]
#[inline]
pub fn init_mut(&mut self) -> &mut [T] {
@ -727,13 +730,13 @@ impl<T> [T] {
}
/// 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 {
core_slice::SliceExt::position_elem(self, t)
}
/// 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 {
core_slice::SliceExt::rposition_elem(self, t)
}
@ -849,7 +852,7 @@ impl<T> [T] {
/// # Examples
///
/// ```rust
/// # #![feature(collections)]
/// # #![feature(permutations)]
/// let v = [1, 2, 3];
/// let mut perms = v.permutations();
///
@ -861,7 +864,7 @@ impl<T> [T] {
/// Iterating through permutations one by one.
///
/// ```rust
/// # #![feature(collections)]
/// # #![feature(permutations)]
/// let v = [1, 2, 3];
/// let mut perms = v.permutations();
///
@ -869,7 +872,9 @@ impl<T> [T] {
/// assert_eq!(Some(vec![1, 3, 2]), perms.next());
/// assert_eq!(Some(vec![3, 1, 2]), perms.next());
/// ```
#[unstable(feature = "collections")]
#[allow(deprecated)]
#[unstable(feature = "permutations")]
#[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")]
#[inline]
pub fn permutations(&self) -> Permutations<T> where T: Clone {
// NB see hack module in this file
@ -884,7 +889,7 @@ impl<T> [T] {
/// # Example
///
/// ```rust
/// # #![feature(collections)]
/// # #![feature(permutations)]
/// let v: &mut [_] = &mut [0, 1, 2];
/// v.next_permutation();
/// let b: &mut [_] = &mut [0, 2, 1];
@ -893,8 +898,10 @@ impl<T> [T] {
/// let b: &mut [_] = &mut [1, 0, 2];
/// assert!(v == b);
/// ```
#[unstable(feature = "collections",
#[allow(deprecated)]
#[unstable(feature = "permutations",
reason = "uncertain if this merits inclusion in std")]
#[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")]
pub fn next_permutation(&mut self) -> bool where T: Ord {
core_slice::SliceExt::next_permutation(self)
}
@ -907,7 +914,7 @@ impl<T> [T] {
/// # Example
///
/// ```rust
/// # #![feature(collections)]
/// # #![feature(permutations)]
/// let v: &mut [_] = &mut [1, 0, 2];
/// v.prev_permutation();
/// let b: &mut [_] = &mut [0, 2, 1];
@ -916,8 +923,10 @@ impl<T> [T] {
/// let b: &mut [_] = &mut [0, 1, 2];
/// assert!(v == b);
/// ```
#[unstable(feature = "collections",
#[allow(deprecated)]
#[unstable(feature = "permutations",
reason = "uncertain if this merits inclusion in std")]
#[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")]
pub fn prev_permutation(&mut self) -> bool where T: Ord {
core_slice::SliceExt::prev_permutation(self)
}
@ -929,7 +938,7 @@ impl<T> [T] {
/// # Example
///
/// ```rust
/// # #![feature(collections)]
/// # #![feature(clone_from_slice)]
/// let mut dst = [0, 0, 0];
/// let src = [1, 2];
///
@ -940,7 +949,7 @@ impl<T> [T] {
/// assert!(dst.clone_from_slice(&src2) == 3);
/// 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 {
core_slice::SliceExt::clone_from_slice(self, src)
}
@ -960,14 +969,14 @@ impl<T> [T] {
/// # Examples
///
/// ```rust
/// # #![feature(collections)]
/// # #![feature(move_from)]
/// let mut a = [1, 2, 3, 4, 5];
/// let b = vec![6, 7, 8];
/// let num_moved = a.move_from(b, 0, 3);
/// assert_eq!(num_moved, 3);
/// assert!(a == [6, 7, 8, 4, 5]);
/// ```
#[unstable(feature = "collections",
#[unstable(feature = "move_from",
reason = "uncertain about this API approach")]
#[inline]
pub fn move_from(&mut self, mut src: Vec<T>, start: usize, end: usize) -> usize {
@ -997,10 +1006,12 @@ impl<T> [T] {
////////////////////////////////////////////////////////////////////////////////
// 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
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
type Output;
@ -1014,8 +1025,8 @@ pub trait SliceConcatExt<T: ?Sized> {
#[stable(feature = "rust1", since = "1.0.0")]
fn concat(&self) -> Self::Output;
/// Flattens a slice of `T` into a single value `Self::Output`, placing a given separator
/// between each.
/// Flattens a slice of `T` into a single value `Self::Output`, placing a
/// given separator between each.
///
/// # Examples
///
@ -1060,8 +1071,10 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
///
/// The last generated swap is always (0, 1), and it returns the
/// sequence to its initial order.
#[unstable(feature = "collections")]
#[allow(deprecated)]
#[unstable(feature = "permutations")]
#[derive(Clone)]
#[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")]
pub struct ElementSwaps {
sdir: Vec<SizeDirection>,
/// If `true`, emit the last swap that returns the sequence to initial
@ -1070,9 +1083,11 @@ pub struct ElementSwaps {
swaps_made : usize,
}
#[allow(deprecated)]
impl ElementSwaps {
/// Creates an `ElementSwaps` iterator for a sequence of `length` elements.
#[unstable(feature = "collections")]
#[unstable(feature = "permutations")]
#[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")]
pub fn new(length: usize) -> ElementSwaps {
// Initialize `sdir` with a direction that position should move in
// (all negative at the beginning) and the `size` of the
@ -1128,6 +1143,7 @@ struct SizeDirection {
}
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl Iterator for ElementSwaps {
type Item = (usize, usize);
@ -1194,13 +1210,16 @@ impl Iterator for ElementSwaps {
/// swap applied.
///
/// Generates even and odd permutations alternately.
#[unstable(feature = "collections")]
#[unstable(feature = "permutations")]
#[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")]
#[allow(deprecated)]
pub struct Permutations<T> {
swaps: ElementSwaps,
v: Vec<T>,
}
#[unstable(feature = "collections", reason = "trait is unstable")]
#[unstable(feature = "permutations", reason = "trait is unstable")]
#[allow(deprecated)]
impl<T: Clone> Iterator for Permutations<T> {
type Item = Vec<T>;

View File

@ -366,7 +366,7 @@ impl<'a> Iterator for Recompositions<'a> {
///
/// For use with the `std::iter` module.
#[derive(Clone)]
#[unstable(feature = "collections")]
#[unstable(feature = "str_utf16")]
pub struct Utf16Units<'a> {
encoder: Utf16Encoder<Chars<'a>>
}
@ -585,13 +585,13 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(slice_chars)]
/// let s = "Löwe 老虎 Léopard";
///
/// assert_eq!(s.slice_chars(0, 4), "Löwe");
/// assert_eq!(s.slice_chars(5, 7), "老虎");
/// ```
#[unstable(feature = "collections",
#[unstable(feature = "slice_chars",
reason = "may have yet to prove its worth")]
pub fn slice_chars(&self, begin: usize, end: usize) -> &str {
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.
#[unstable(feature = "collections",
#[unstable(feature = "str_utf16",
reason = "this functionality may only be provided by libunicode")]
pub fn utf16_units(&self) -> Utf16Units {
Utf16Units { encoder: Utf16Encoder::new(self[..].chars()) }
@ -1520,15 +1520,13 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let v: Vec<&str> = "abcXXXabcYYYabc".matches("abc").collect();
/// assert_eq!(v, ["abc", "abc", "abc"]);
///
/// let v: Vec<&str> = "1abc2abc3".matches(char::is_numeric).collect();
/// assert_eq!(v, ["1", "2", "3"]);
/// ```
#[unstable(feature = "collections",
reason = "method got recently added")]
#[stable(feature = "str_matches", since = "1.2.0")]
pub fn matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> Matches<'a, P> {
core_str::StrExt::matches(self, pat)
}
@ -1553,15 +1551,13 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let v: Vec<&str> = "abcXXXabcYYYabc".rmatches("abc").collect();
/// assert_eq!(v, ["abc", "abc", "abc"]);
///
/// let v: Vec<&str> = "1abc2abc3".rmatches(char::is_numeric).collect();
/// assert_eq!(v, ["3", "2", "1"]);
/// ```
#[unstable(feature = "collections",
reason = "method got recently added")]
#[stable(feature = "str_matches", since = "1.2.0")]
pub fn rmatches<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatches<'a, P>
where P::Searcher: ReverseSearcher<'a>
{
@ -1595,7 +1591,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(str_match_indices)]
/// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".match_indices("abc").collect();
/// assert_eq!(v, [(0, 3), (6, 9), (12, 15)]);
///
@ -1605,7 +1601,7 @@ impl str {
/// let v: Vec<(usize, usize)> = "ababa".match_indices("aba").collect();
/// assert_eq!(v, [(0, 3)]); // only the first `aba`
/// ```
#[unstable(feature = "collections",
#[unstable(feature = "str_match_indices",
reason = "might have its iterator type changed")]
// NB: Right now MatchIndices yields `(usize, usize)`, but it would
// be more consistent with `matches` and `char_indices` to return `(usize, &str)`
@ -1639,7 +1635,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(str_match_indices)]
/// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".rmatch_indices("abc").collect();
/// assert_eq!(v, [(12, 15), (6, 9), (0, 3)]);
///
@ -1649,7 +1645,7 @@ impl str {
/// let v: Vec<(usize, usize)> = "ababa".rmatch_indices("aba").collect();
/// assert_eq!(v, [(2, 5)]); // only the last `aba`
/// ```
#[unstable(feature = "collections",
#[unstable(feature = "str_match_indices",
reason = "might have its iterator type changed")]
// NB: Right now RMatchIndices yields `(usize, usize)`, but it would
// be more consistent with `rmatches` and `char_indices` to return `(usize, &str)`
@ -1669,7 +1665,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(subslice_offset)]
/// let string = "a\nb\nc";
/// let lines: Vec<&str> = string.lines().collect();
///
@ -1677,7 +1673,7 @@ impl str {
/// assert!(string.subslice_offset(lines[1]) == 2); // &"b"
/// assert!(string.subslice_offset(lines[2]) == 4); // &"c"
/// ```
#[unstable(feature = "collections",
#[unstable(feature = "subslice_offset",
reason = "awaiting convention about comparability of arbitrary slices")]
pub fn subslice_offset(&self, inner: &str) -> usize {
core_str::StrExt::subslice_offset(self, inner)
@ -1863,7 +1859,7 @@ impl str {
/// # Examples
///
/// ```
/// #![feature(collections)]
/// #![feature(str_casing)]
///
/// let s = "HELLO";
/// assert_eq!(s.to_lowercase(), "hello");
@ -1909,7 +1905,7 @@ impl str {
/// # Examples
///
/// ```
/// #![feature(collections)]
/// #![feature(str_casing)]
///
/// let s = "hello";
/// assert_eq!(s.to_uppercase(), "HELLO");
@ -1922,14 +1918,14 @@ impl str {
}
/// 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")]
pub fn escape_default(&self) -> String {
self.chars().flat_map(|c| c.escape_default()).collect()
}
/// 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")]
pub fn escape_unicode(&self) -> String {
self.chars().flat_map(|c| c.escape_unicode()).collect()

View File

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

View File

@ -276,8 +276,10 @@ impl<T> Vec<T> {
/// the buffer are copied into the vector without cloning, as if
/// `ptr::read()` were called on them.
#[inline]
#[unstable(feature = "collections",
#[unstable(feature = "vec_from_raw_buf",
reason = "may be better expressed via composition")]
#[deprecated(since = "1.2.0",
reason = "use slice::from_raw_parts + .to_vec() instead")]
pub unsafe fn from_raw_buf(ptr: *const T, elts: usize) -> Vec<T> {
let mut dst = Vec::with_capacity(elts);
dst.set_len(elts);
@ -696,7 +698,7 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(append)]
/// let mut vec = vec![1, 2, 3];
/// let mut vec2 = vec![4, 5, 6];
/// vec.append(&mut vec2);
@ -704,7 +706,7 @@ impl<T> Vec<T> {
/// assert_eq!(vec2, []);
/// ```
#[inline]
#[unstable(feature = "collections",
#[unstable(feature = "append",
reason = "new API, waiting for dust to settle")]
pub fn append(&mut self, other: &mut Self) {
if mem::size_of::<T>() == 0 {
@ -742,7 +744,7 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections_drain)]
/// # #![feature(drain)]
///
/// // Draining using `..` clears the whole vector.
/// let mut v = vec![1, 2, 3];
@ -750,7 +752,7 @@ impl<T> Vec<T> {
/// assert_eq!(v, &[]);
/// assert_eq!(u, &[1, 2, 3]);
/// ```
#[unstable(feature = "collections_drain",
#[unstable(feature = "drain",
reason = "recently added, matches RFC")]
pub fn drain<R>(&mut self, range: R) -> Drain<T> where R: RangeArgument<usize> {
// Memory safety
@ -840,7 +842,7 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(map_in_place)]
/// let v = vec![0, 1, 2];
/// let w = v.map_in_place(|i| i + 3);
/// assert_eq!(&w[..], &[3, 4, 5]);
@ -851,7 +853,7 @@ impl<T> Vec<T> {
/// let newtyped_bytes = bytes.map_in_place(|x| Newtype(x));
/// assert_eq!(&newtyped_bytes[..], &[Newtype(0x11), Newtype(0x22)]);
/// ```
#[unstable(feature = "collections",
#[unstable(feature = "map_in_place",
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 {
// FIXME: Assert statically that the types `T` and `U` have the same
@ -1043,14 +1045,14 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(split_off)]
/// let mut vec = vec![1,2,3];
/// let vec2 = vec.split_off(1);
/// assert_eq!(vec, [1]);
/// assert_eq!(vec2, [2, 3]);
/// ```
#[inline]
#[unstable(feature = "collections",
#[unstable(feature = "split_off",
reason = "new API, waiting for dust to settle")]
pub fn split_off(&mut self, at: usize) -> Self {
assert!(at <= self.len(), "`at` out of bounds");
@ -1082,7 +1084,7 @@ impl<T: Clone> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vec_resize)]
/// let mut vec = vec!["hello"];
/// vec.resize(3, "world");
/// assert_eq!(vec, ["hello", "world", "world"]);
@ -1091,7 +1093,7 @@ impl<T: Clone> Vec<T> {
/// vec.resize(2, 0);
/// assert_eq!(vec, [1, 2]);
/// ```
#[unstable(feature = "collections",
#[unstable(feature = "vec_resize",
reason = "matches collection reform specification; waiting for dust to settle")]
pub fn resize(&mut self, new_len: usize, value: T) {
let len = self.len();
@ -1111,13 +1113,13 @@ impl<T: Clone> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vec_push_all)]
/// let mut vec = vec![1];
/// vec.push_all(&[2, 3, 4]);
/// assert_eq!(vec, [1, 2, 3, 4]);
/// ```
#[inline]
#[unstable(feature = "collections",
#[unstable(feature = "vec_push_all",
reason = "likely to be replaced by a more optimized extend")]
pub fn push_all(&mut self, other: &[T]) {
self.reserve(other.len());
@ -1707,12 +1709,14 @@ impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone {
}
}
#[allow(deprecated)]
impl<'a, T: 'a> IntoCow<'a, [T]> for Vec<T> where T: Clone {
fn into_cow(self) -> Cow<'a, [T]> {
Cow::Owned(self)
}
}
#[allow(deprecated)]
impl<'a, T> IntoCow<'a, [T]> for &'a [T] where T: Clone {
fn into_cow(self) -> Cow<'a, [T]> {
Cow::Borrowed(self)
@ -1738,7 +1742,7 @@ unsafe impl<T: Sync> Sync for IntoIter<T> { }
impl<T> IntoIter<T> {
#[inline]
/// 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> {
unsafe {
for _x in self.by_ref() { }
@ -1832,7 +1836,7 @@ impl<T> Drop for IntoIter<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> {
/// Index of tail to preserve
tail_start: usize,
@ -1907,12 +1911,17 @@ impl<'a, T> ExactSizeIterator for Drain<'a, T> {}
/// Wrapper type providing a `&Vec<T>` reference via `Deref`.
#[unstable(feature = "collections")]
#[deprecated(since = "1.2.0",
reason = "replaced with deref coercions or Borrow")]
pub struct DerefVec<'a, T:'a> {
x: Vec<T>,
l: PhantomData<&'a T>,
}
#[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> {
type Target = Vec<T>;
@ -1923,6 +1932,9 @@ impl<'a, T> Deref for DerefVec<'a, T> {
// Prevent the inner `Vec<T>` from attempting to deallocate memory.
#[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> {
fn drop(&mut self) {
self.x.len = 0;
@ -1948,6 +1960,9 @@ impl<'a, T> Drop for DerefVec<'a, T> {
/// vec_consumer(&as_vec(&values));
/// ```
#[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> {
unsafe {
DerefVec {

View File

@ -480,7 +480,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(deque_extras)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
@ -491,7 +491,7 @@ impl<T> VecDeque<T> {
/// assert_eq!(buf.len(), 1);
/// assert_eq!(Some(&5), buf.get(0));
/// ```
#[unstable(feature = "collections",
#[unstable(feature = "deque_extras",
reason = "matches collection reform specification; waiting on panic semantics")]
pub fn truncate(&mut self, len: usize) {
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
/// `VecDeque`.
#[inline]
#[unstable(feature = "collections",
#[unstable(feature = "deque_extras",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn as_slices(&self) -> (&[T], &[T]) {
unsafe {
@ -572,7 +572,7 @@ impl<T> VecDeque<T> {
/// Returns a pair of slices which contain, in order, the contents of the
/// `VecDeque`.
#[inline]
#[unstable(feature = "collections",
#[unstable(feature = "deque_extras",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T]) {
unsafe {
@ -629,7 +629,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(drain)]
/// use std::collections::VecDeque;
///
/// let mut v = VecDeque::new();
@ -638,7 +638,7 @@ impl<T> VecDeque<T> {
/// assert!(v.is_empty());
/// ```
#[inline]
#[unstable(feature = "collections",
#[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn drain(&mut self) -> Drain<T> {
Drain {
@ -868,7 +868,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(deque_extras)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
@ -880,7 +880,7 @@ impl<T> VecDeque<T> {
/// buf.push_back(10);
/// 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")]
pub fn swap_back_remove(&mut self, index: usize) -> Option<T> {
let length = self.len();
@ -892,8 +892,8 @@ impl<T> VecDeque<T> {
self.pop_back()
}
/// Removes an element from anywhere in the ringbuf and returns it, replacing it with the first
/// element.
/// Removes an element from anywhere in the ringbuf and returns it,
/// replacing it with the first element.
///
/// This does not preserve ordering, but is O(1).
///
@ -902,7 +902,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(deque_extras)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
@ -914,7 +914,7 @@ impl<T> VecDeque<T> {
/// buf.push_back(20);
/// 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")]
pub fn swap_front_remove(&mut self, index: usize) -> Option<T> {
let length = self.len();
@ -1310,7 +1310,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(split_off)]
/// use std::collections::VecDeque;
///
/// let mut buf: VecDeque<_> = vec![1,2,3].into_iter().collect();
@ -1320,7 +1320,7 @@ impl<T> VecDeque<T> {
/// assert_eq!(buf2.len(), 2);
/// ```
#[inline]
#[unstable(feature = "collections",
#[unstable(feature = "split_off",
reason = "new API, waiting for dust to settle")]
pub fn split_off(&mut self, at: usize) -> Self {
let len = self.len();
@ -1373,7 +1373,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(append)]
/// use std::collections::VecDeque;
///
/// let mut buf: VecDeque<_> = vec![1, 2, 3].into_iter().collect();
@ -1383,7 +1383,7 @@ impl<T> VecDeque<T> {
/// assert_eq!(buf2.len(), 0);
/// ```
#[inline]
#[unstable(feature = "collections",
#[unstable(feature = "append",
reason = "new API, waiting for dust to settle")]
pub fn append(&mut self, other: &mut Self) {
// naive impl
@ -1434,7 +1434,7 @@ impl<T: Clone> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(deque_extras)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
@ -1447,7 +1447,7 @@ impl<T: Clone> VecDeque<T> {
/// assert_eq!(a, b);
/// }
/// ```
#[unstable(feature = "collections",
#[unstable(feature = "deque_extras",
reason = "matches collection reform specification; waiting on panic semantics")]
pub fn resize(&mut self, new_len: usize, value: T) {
let len = self.len();
@ -1530,6 +1530,7 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
impl<'a, T> ExactSizeIterator for Iter<'a, T> {}
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl<'a, T> RandomAccessIterator for Iter<'a, T> {
#[inline]
fn indexable(&self) -> usize {
@ -1635,7 +1636,7 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
impl<T> ExactSizeIterator for IntoIter<T> {}
/// A draining VecDeque iterator
#[unstable(feature = "collections",
#[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle")]
pub struct Drain<'a, T: 'a> {
inner: &'a mut VecDeque<T>,

View File

@ -12,6 +12,8 @@
//! are O(highest integer key).
#![allow(missing_docs)]
#![unstable(feature = "vecmap",
reason = "may not be stabilized in the standard library")]
use self::Entry::*;
@ -33,7 +35,7 @@ use vec::Vec;
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
///
/// let mut months = VecMap::new();
@ -133,7 +135,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
/// let mut map: VecMap<&str> = VecMap::new();
/// ```
@ -146,7 +148,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
/// let mut map: VecMap<&str> = VecMap::with_capacity(10);
/// ```
@ -161,7 +163,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
/// let map: VecMap<String> = VecMap::with_capacity(10);
/// assert!(map.capacity() >= 10);
@ -181,7 +183,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
/// let mut map: VecMap<&str> = VecMap::new();
/// map.reserve_len(10);
@ -206,7 +208,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
/// let mut map: VecMap<&str> = VecMap::new();
/// map.reserve_len_exact(10);
@ -246,7 +248,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -275,7 +277,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -305,7 +307,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap, append)]
/// use std::collections::VecMap;
///
/// let mut a = VecMap::new();
@ -325,7 +327,7 @@ impl<V> VecMap<V> {
/// assert_eq!(a[3], "c");
/// assert_eq!(a[4], "d");
/// ```
#[unstable(feature = "collections",
#[unstable(feature = "append",
reason = "recently added as part of collections reform 2")]
pub fn append(&mut self, other: &mut Self) {
self.extend(other.drain());
@ -341,7 +343,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap, split_off)]
/// use std::collections::VecMap;
///
/// let mut a = VecMap::new();
@ -358,7 +360,7 @@ impl<V> VecMap<V> {
/// assert_eq!(b[3], "c");
/// assert_eq!(b[4], "d");
/// ```
#[unstable(feature = "collections",
#[unstable(feature = "split_off",
reason = "recently added as part of collections reform 2")]
pub fn split_off(&mut self, at: usize) -> Self {
let mut other = VecMap::new();
@ -398,7 +400,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap, drain)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -410,7 +412,7 @@ impl<V> VecMap<V> {
///
/// 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")]
pub fn drain<'a>(&'a mut self) -> Drain<'a, V> {
fn filter<A>((i, v): (usize, Option<A>)) -> Option<(usize, A)> {
@ -426,7 +428,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
///
/// let mut a = VecMap::new();
@ -444,7 +446,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
///
/// let mut a = VecMap::new();
@ -462,7 +464,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
///
/// let mut a = VecMap::new();
@ -478,7 +480,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -503,7 +505,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -522,7 +524,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -550,7 +552,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -576,7 +578,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -598,7 +600,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap, entry)]
/// use std::collections::VecMap;
///
/// let mut count: VecMap<u32> = VecMap::new();
@ -632,7 +634,7 @@ impl<V> VecMap<V> {
impl<'a, V> Entry<'a, V> {
#[unstable(feature = "collections",
#[unstable(feature = "entry",
reason = "will soon be replaced by or_insert")]
#[deprecated(since = "1.0",
reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")]
@ -644,10 +646,9 @@ impl<'a, V> Entry<'a, V> {
}
}
#[unstable(feature = "collections",
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
/// a mutable reference to the value in the entry.
#[stable(feature = "vecmap_entry", since = "1.2.0")]
/// Ensures a value is in the entry by inserting the default if empty, and
/// returns a mutable reference to the value in the entry.
pub fn or_insert(self, default: V) -> &'a mut V {
match self {
Occupied(entry) => entry.into_mut(),
@ -655,10 +656,10 @@ impl<'a, V> Entry<'a, V> {
}
}
#[unstable(feature = "collections",
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,
/// and returns a mutable reference to the value in the entry.
#[stable(feature = "vecmap_entry", since = "1.2.0")]
/// 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.
pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
match self {
Occupied(entry) => entry.into_mut(),
@ -777,7 +778,7 @@ impl<T> IntoIterator for VecMap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// # #![feature(vecmap)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -1003,14 +1004,14 @@ pub struct IntoIter<V> {
fn((usize, Option<V>)) -> Option<(usize, V)>>
}
#[unstable(feature = "collections")]
#[unstable(feature = "drain")]
pub struct Drain<'a, V:'a> {
iter: FilterMap<
Enumerate<vec::Drain<'a, Option<V>>>,
fn((usize, Option<V>)) -> Option<(usize, V)>>
}
#[unstable(feature = "collections")]
#[unstable(feature = "drain")]
impl<'a, V> Iterator for Drain<'a, V> {
type Item = (usize, V);
@ -1018,7 +1019,7 @@ impl<'a, V> Iterator for Drain<'a, V> {
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> {
fn next_back(&mut self) -> Option<(usize, V)> { self.iter.next_back() }
}

View File

@ -8,23 +8,52 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(bit_set_append_split_off)]
#![feature(append)]
#![feature(bit_vec_append_split_off)]
#![feature(bitset)]
#![feature(bitvec)]
#![feature(box_syntax)]
#![feature(btree_range)]
#![feature(collections)]
#![feature(collections_drain)]
#![feature(core)]
#![feature(collections_bound)]
#![feature(const_fn)]
#![feature(hash)]
#![feature(core)]
#![feature(deque_extras)]
#![feature(drain)]
#![feature(enumset)]
#![feature(hash_default)]
#![feature(into_cow)]
#![feature(iter_idx)]
#![feature(iter_order)]
#![feature(iter_arith)]
#![feature(iter_to_vec)]
#![feature(map_in_place)]
#![feature(move_from)]
#![feature(num_bits_bytes)]
#![feature(pattern)]
#![feature(permutations)]
#![feature(rand)]
#![feature(range_inclusive)]
#![feature(rustc_private)]
#![feature(slice_bytes)]
#![feature(slice_chars)]
#![feature(slice_extras)]
#![feature(slice_position_elem)]
#![feature(split_off)]
#![feature(step_by)]
#![feature(str_char)]
#![feature(str_escape)]
#![feature(str_match_indices)]
#![feature(str_utf16)]
#![feature(subslice_offset)]
#![feature(test)]
#![feature(unboxed_closures)]
#![feature(unicode)]
#![feature(into_cow)]
#![feature(step_by)]
#![cfg_attr(test, feature(str_char))]
#![cfg_attr(test, feature(vec_deque_retain))]
#![feature(vec_deque_retain)]
#![feature(vec_from_raw_buf)]
#![feature(vec_push_all)]
#![feature(vec_split_off)]
#![feature(vecmap)]
#[macro_use] extern crate log;

View File

@ -9,7 +9,7 @@
// except according to those terms.
use std::cmp::Ordering::{Equal, Greater, Less};
use std::str::{Utf8Error, from_utf8};
use std::str::from_utf8;
#[test]
fn test_le() {
@ -1753,6 +1753,7 @@ mod pattern {
macro_rules! make_test {
($name:ident, $p:expr, $h:expr, [$($e:expr,)*]) => {
#[allow(unused_imports)]
mod $name {
use std::str::pattern::SearchStep::{Match, Reject};
use super::{cmp_search_to_vec};

View File

@ -10,12 +10,13 @@
use std::borrow::{IntoCow, Cow};
use std::iter::repeat;
use std::str::Utf8Error;
#[allow(deprecated)]
use std::string::as_string;
use test::Bencher;
#[test]
#[allow(deprecated)]
fn test_as_string() {
let x = "foo";
assert_eq!(x, &**as_string(x));

View File

@ -10,6 +10,7 @@
use std::iter::{FromIterator, repeat};
use std::mem::size_of;
#[allow(deprecated)]
use std::vec::as_vec;
use test::Bencher;
@ -25,12 +26,14 @@ impl<'a> Drop for DropCounter<'a> {
}
#[test]
#[allow(deprecated)]
fn test_as_vec() {
let xs = [1u8, 2u8, 3u8];
assert_eq!(&**as_vec(&xs), xs);
}
#[test]
#[allow(deprecated)]
fn test_as_vec_dtor() {
let (mut count_x, mut count_y) = (0, 0);
{

View File

@ -537,8 +537,6 @@ fn test_drain() {
#[test]
fn test_from_iter() {
use std::iter;
let v = vec!(1,2,3,4,5,6,7);
let deq: VecDeque<_> = v.iter().cloned().collect();
let u: Vec<_> = deq.iter().cloned().collect();

View File

@ -92,7 +92,7 @@ use marker::{Reflect, Sized};
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Any: Reflect + 'static {
/// Gets the `TypeId` of `self`.
#[unstable(feature = "core",
#[unstable(feature = "get_type_id",
reason = "this method will likely be replaced by an associated static")]
fn get_type_id(&self) -> TypeId;
}

View File

@ -12,9 +12,10 @@
//! up to a certain length. Eventually we should able to generalize
//! to all lengths.
#![unstable(feature = "core")] // not yet reviewed
#![doc(primitive = "array")]
#![unstable(feature = "fixed_size_array",
reason = "traits and impls are better expressed through generic \
integer constants")]
use clone::Clone;
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
@ -30,7 +31,6 @@ use slice::{Iter, IterMut, SliceExt};
///
/// This trait can be used to implement other traits on fixed-size arrays
/// without causing much metadata bloat.
#[unstable(feature = "core")]
pub trait FixedSizeArray<T> {
/// Converts the array to immutable slice
fn as_slice(&self) -> &[T];
@ -42,7 +42,6 @@ pub trait FixedSizeArray<T> {
macro_rules! array_impls {
($($N:expr)+) => {
$(
#[unstable(feature = "core")]
impl<T> FixedSizeArray<T> for [T; $N] {
#[inline]
fn as_slice(&self) -> &[T] {
@ -54,8 +53,6 @@ macro_rules! array_impls {
}
}
#[unstable(feature = "array_as_ref",
reason = "should ideally be implemented for all fixed-sized arrays")]
impl<T> AsRef<[T]> for [T; $N] {
#[inline]
fn as_ref(&self) -> &[T] {
@ -63,8 +60,6 @@ macro_rules! array_impls {
}
}
#[unstable(feature = "array_as_ref",
reason = "should ideally be implemented for all fixed-sized arrays")]
impl<T> AsMut<[T]> for [T; $N] {
#[inline]
fn as_mut(&mut self) -> &mut [T] {

View File

@ -221,7 +221,7 @@ impl<T:Copy> Cell<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(as_unsafe_cell)]
/// use std::cell::Cell;
///
/// let c = Cell::new(5);
@ -229,7 +229,7 @@ impl<T:Copy> Cell<T> {
/// let uc = unsafe { c.as_unsafe_cell() };
/// ```
#[inline]
#[unstable(feature = "core")]
#[unstable(feature = "as_unsafe_cell")]
pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell<T> {
&self.value
}
@ -277,7 +277,7 @@ pub struct RefCell<T: ?Sized> {
/// An enumeration of values returned from the `state` method on a `RefCell<T>`.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[unstable(feature = "std_misc")]
#[unstable(feature = "borrow_state")]
pub enum BorrowState {
/// The cell is currently being read, there is at least one active `borrow`.
Reading,
@ -339,7 +339,7 @@ impl<T: ?Sized> RefCell<T> {
///
/// The returned value can be dispatched on to determine if a call to
/// `borrow` or `borrow_mut` would succeed.
#[unstable(feature = "std_misc")]
#[unstable(feature = "borrow_state")]
#[inline]
pub fn borrow_state(&self) -> BorrowState {
match self.borrow.get() {
@ -448,7 +448,7 @@ impl<T: ?Sized> RefCell<T> {
///
/// This function is `unsafe` because `UnsafeCell`'s field is public.
#[inline]
#[unstable(feature = "core")]
#[unstable(feature = "as_unsafe_cell")]
pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell<T> {
&self.value
}
@ -564,9 +564,10 @@ impl<'b, T: ?Sized> Ref<'b, T> {
///
/// The `RefCell` is already immutably borrowed, so this cannot fail.
///
/// This is an associated function that needs to be used as `Ref::clone(...)`.
/// A `Clone` implementation or a method would interfere with the widespread
/// use of `r.borrow().clone()` to clone the contents of a `RefCell`.
/// This is an associated function that needs to be used as
/// `Ref::clone(...)`. A `Clone` implementation or a method would interfere
/// with the widespread use of `r.borrow().clone()` to clone the contents of
/// a `RefCell`.
#[unstable(feature = "cell_extras",
reason = "likely to be moved to a method, pending language changes")]
#[inline]
@ -582,8 +583,8 @@ impl<'b, T: ?Sized> Ref<'b, T> {
/// The `RefCell` is already immutably borrowed, so this cannot fail.
///
/// This is an associated function that needs to be used as `Ref::map(...)`.
/// A method would interfere with methods of the same name on the contents of a `RefCell`
/// used through `Deref`.
/// A method would interfere with methods of the same name on the contents
/// of a `RefCell` used through `Deref`.
///
/// # Example
///
@ -607,13 +608,14 @@ impl<'b, T: ?Sized> Ref<'b, T> {
}
}
/// Make a new `Ref` for a optional component of the borrowed data, e.g. an enum variant.
/// Make a new `Ref` for a optional component of the borrowed data, e.g. an
/// enum variant.
///
/// The `RefCell` is already immutably borrowed, so this cannot fail.
///
/// This is an associated function that needs to be used as `Ref::filter_map(...)`.
/// A method would interfere with methods of the same name on the contents of a `RefCell`
/// used through `Deref`.
/// This is an associated function that needs to be used as
/// `Ref::filter_map(...)`. A method would interfere with methods of the
/// same name on the contents of a `RefCell` used through `Deref`.
///
/// # Example
///
@ -639,13 +641,14 @@ impl<'b, T: ?Sized> Ref<'b, T> {
}
impl<'b, T: ?Sized> RefMut<'b, T> {
/// Make a new `RefMut` for a component of the borrowed data, e.g. an enum variant.
/// Make a new `RefMut` for a component of the borrowed data, e.g. an enum
/// variant.
///
/// The `RefCell` is already mutably borrowed, so this cannot fail.
///
/// This is an associated function that needs to be used as `RefMut::map(...)`.
/// A method would interfere with methods of the same name on the contents of a `RefCell`
/// used through `Deref`.
/// This is an associated function that needs to be used as
/// `RefMut::map(...)`. A method would interfere with methods of the same
/// name on the contents of a `RefCell` used through `Deref`.
///
/// # Example
///
@ -673,13 +676,14 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
}
}
/// Make a new `RefMut` for a optional component of the borrowed data, e.g. an enum variant.
/// Make a new `RefMut` for a optional component of the borrowed data, e.g.
/// an enum variant.
///
/// The `RefCell` is already mutably borrowed, so this cannot fail.
///
/// This is an associated function that needs to be used as `RefMut::filter_map(...)`.
/// A method would interfere with methods of the same name on the contents of a `RefCell`
/// used through `Deref`.
/// This is an associated function that needs to be used as
/// `RefMut::filter_map(...)`. A method would interfere with methods of the
/// same name on the contents of a `RefCell` used through `Deref`.
///
/// # Example
///
@ -690,7 +694,9 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
/// let c = RefCell::new(Ok(5));
/// {
/// let b1: RefMut<Result<u32, ()>> = c.borrow_mut();
/// let mut b2: RefMut<u32> = RefMut::filter_map(b1, |o| o.as_mut().ok()).unwrap();
/// let mut b2: RefMut<u32> = RefMut::filter_map(b1, |o| {
/// o.as_mut().ok()
/// }).unwrap();
/// assert_eq!(*b2, 5);
/// *b2 = 42;
/// }

View File

@ -14,6 +14,7 @@
#![allow(non_snake_case)]
#![doc(primitive = "char")]
#![stable(feature = "core_char", since = "1.2.0")]
use iter::Iterator;
use mem::transmute;
@ -131,6 +132,8 @@ pub fn from_digit(num: u32, radix: u32) -> Option<char> {
// unicode/char.rs, not here
#[allow(missing_docs)] // docs in libunicode/u_char.rs
#[doc(hidden)]
#[unstable(feature = "core_char_ext",
reason = "the stable interface is `impl char` in later crate")]
pub trait CharExt {
fn is_digit(self, radix: u32) -> bool;
fn to_digit(self, radix: u32) -> Option<u32>;
@ -220,6 +223,9 @@ impl CharExt for char {
/// If the buffer is not large enough, nothing will be written into it
/// and a `None` will be returned.
#[inline]
#[unstable(feature = "char_internals",
reason = "this function should not be exposed publicly")]
#[doc(hidden)]
pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option<usize> {
// Marked #[inline] to allow llvm optimizing it away
if code < MAX_ONE_B && !dst.is_empty() {
@ -251,6 +257,9 @@ pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option<usize> {
/// If the buffer is not large enough, nothing will be written into it
/// and a `None` will be returned.
#[inline]
#[unstable(feature = "char_internals",
reason = "this function should not be exposed publicly")]
#[doc(hidden)]
pub fn encode_utf16_raw(mut ch: u32, dst: &mut [u16]) -> Option<usize> {
// Marked #[inline] to allow llvm optimizing it away
if (ch & 0xFFFF) == ch && !dst.is_empty() {

View File

@ -89,29 +89,28 @@ clone_impl! { char }
macro_rules! extern_fn_clone {
($($A:ident),*) => (
#[unstable(feature = "core",
reason = "this may not be sufficient for fns with region parameters")]
#[stable(feature = "rust1", since = "1.0.0")]
impl<$($A,)* ReturnType> Clone for extern "Rust" fn($($A),*) -> ReturnType {
/// Returns a copy of a function pointer.
#[inline]
fn clone(&self) -> extern "Rust" fn($($A),*) -> ReturnType { *self }
}
#[unstable(feature = "core", reason = "brand new")]
#[stable(feature = "rust1", since = "1.0.0")]
impl<$($A,)* ReturnType> Clone for extern "C" fn($($A),*) -> ReturnType {
/// Returns a copy of a function pointer.
#[inline]
fn clone(&self) -> extern "C" fn($($A),*) -> ReturnType { *self }
}
#[unstable(feature = "core", reason = "brand new")]
#[stable(feature = "rust1", since = "1.0.0")]
impl<$($A,)* ReturnType> Clone for unsafe extern "Rust" fn($($A),*) -> ReturnType {
/// Returns a copy of a function pointer.
#[inline]
fn clone(&self) -> unsafe extern "Rust" fn($($A),*) -> ReturnType { *self }
}
#[unstable(feature = "core", reason = "brand new")]
#[stable(feature = "rust1", since = "1.0.0")]
impl<$($A,)* ReturnType> Clone for unsafe extern "C" fn($($A),*) -> ReturnType {
/// Returns a copy of a function pointer.
#[inline]

View File

@ -10,10 +10,10 @@
//! Functionality for ordering and comparison.
//!
//! This module defines both `PartialOrd` and `PartialEq` traits which are used by the compiler to
//! implement comparison operators. Rust programs may implement `PartialOrd` to overload the `<`,
//! `<=`, `>`, and `>=` operators, and may implement `PartialEq` to overload the `==` and `!=`
//! operators.
//! This module defines both `PartialOrd` and `PartialEq` traits which are used
//! by the compiler to implement comparison operators. Rust programs may
//! implement `PartialOrd` to overload the `<`, `<=`, `>`, and `>=` operators,
//! and may implement `PartialEq` to overload the `==` and `!=` operators.
#![stable(feature = "rust1", since = "1.0.0")]
@ -22,29 +22,31 @@ use self::Ordering::*;
use marker::Sized;
use option::Option::{self, Some, None};
/// Trait for equality comparisons which are [partial equivalence relations](
/// http://en.wikipedia.org/wiki/Partial_equivalence_relation).
/// Trait for equality comparisons which are [partial equivalence
/// relations](http://en.wikipedia.org/wiki/Partial_equivalence_relation).
///
/// This trait allows for partial equality, for types that do not have a full equivalence relation.
/// For example, in floating point numbers `NaN != NaN`, so floating point types implement
/// `PartialEq` but not `Eq`.
/// This trait allows for partial equality, for types that do not have a full
/// equivalence relation. For example, in floating point numbers `NaN != NaN`,
/// so floating point types implement `PartialEq` but not `Eq`.
///
/// Formally, the equality must be (for all `a`, `b` and `c`):
///
/// - symmetric: `a == b` implies `b == a`; and
/// - transitive: `a == b` and `b == c` implies `a == c`.
///
/// Note that these requirements mean that the trait itself must be implemented symmetrically and
/// transitively: if `T: PartialEq<U>` and `U: PartialEq<V>` then `U: PartialEq<T>` and `T:
/// PartialEq<V>`.
/// Note that these requirements mean that the trait itself must be implemented
/// symmetrically and transitively: if `T: PartialEq<U>` and `U: PartialEq<V>`
/// then `U: PartialEq<T>` and `T: PartialEq<V>`.
///
/// PartialEq only requires the `eq` method to be implemented; `ne` is defined in terms of it by
/// default. Any manual implementation of `ne` *must* respect the rule that `eq` is a strict
/// inverse of `ne`; that is, `!(a == b)` if and only if `a != b`.
/// PartialEq only requires the `eq` method to be implemented; `ne` is defined
/// in terms of it by default. Any manual implementation of `ne` *must* respect
/// the rule that `eq` is a strict inverse of `ne`; that is, `!(a == b)` if and
/// only if `a != b`.
#[lang = "eq"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait PartialEq<Rhs: ?Sized = Self> {
/// This method tests for `self` and `other` values to be equal, and is used by `==`.
/// This method tests for `self` and `other` values to be equal, and is used
/// by `==`.
#[stable(feature = "rust1", since = "1.0.0")]
fn eq(&self, other: &Rhs) -> bool;
@ -379,7 +381,7 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(cmp_partial)]
/// use std::cmp;
///
/// assert_eq!(Some(1), cmp::partial_min(1, 2));
@ -389,14 +391,14 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
/// When comparison is impossible:
///
/// ```
/// # #![feature(core)]
/// # #![feature(cmp_partial)]
/// use std::cmp;
///
/// let result = cmp::partial_min(std::f64::NAN, 1.0);
/// assert_eq!(result, None);
/// ```
#[inline]
#[unstable(feature = "core")]
#[unstable(feature = "cmp_partial")]
pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
match v1.partial_cmp(&v2) {
Some(Less) | Some(Equal) => Some(v1),
@ -412,7 +414,7 @@ pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(cmp_partial)]
/// use std::cmp;
///
/// assert_eq!(Some(2), cmp::partial_max(1, 2));
@ -422,14 +424,14 @@ pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
/// When comparison is impossible:
///
/// ```
/// # #![feature(core)]
/// # #![feature(cmp_partial)]
/// use std::cmp;
///
/// let result = cmp::partial_max(std::f64::NAN, 1.0);
/// assert_eq!(result, None);
/// ```
#[inline]
#[unstable(feature = "core")]
#[unstable(feature = "cmp_partial")]
pub fn partial_max<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
match v1.partial_cmp(&v2) {
Some(Equal) | Some(Less) => Some(v2),

View File

@ -10,11 +10,12 @@
//! Traits for conversions between types.
//!
//! The traits in this module provide a general way to talk about conversions from one type to
//! another. They follow the standard Rust conventions of `as`/`into`/`from`.
//! The traits in this module provide a general way to talk about conversions
//! from one type to another. They follow the standard Rust conventions of
//! `as`/`into`/`from`.
//!
//! Like many traits, these are often used as bounds for generic functions, to support arguments of
//! multiple types.
//! Like many traits, these are often used as bounds for generic functions, to
//! support arguments of multiple types.
//!
//! See each trait for usage examples.

View File

@ -33,7 +33,7 @@ pub use self::builders::{DebugStruct, DebugTuple, DebugSet, DebugList, DebugMap}
mod num;
mod builders;
#[unstable(feature = "core", reason = "internal to format_args!")]
#[unstable(feature = "fmt_internals", reason = "internal to format_args!")]
#[doc(hidden)]
pub mod rt {
pub mod v1;
@ -146,7 +146,7 @@ enum Void {}
/// compile time it is ensured that the function and the value have the correct
/// types, and then this struct is used to canonicalize arguments to one type.
#[derive(Copy)]
#[unstable(feature = "core", reason = "internal to format_args!")]
#[unstable(feature = "fmt_internals", reason = "internal to format_args!")]
#[doc(hidden)]
pub struct ArgumentV1<'a> {
value: &'a Void,
@ -166,7 +166,7 @@ impl<'a> ArgumentV1<'a> {
}
#[doc(hidden)]
#[unstable(feature = "core", reason = "internal to format_args!")]
#[unstable(feature = "fmt_internals", reason = "internal to format_args!")]
pub fn new<'b, T>(x: &'b T,
f: fn(&T, &mut Formatter) -> Result) -> ArgumentV1<'b> {
unsafe {
@ -178,7 +178,7 @@ impl<'a> ArgumentV1<'a> {
}
#[doc(hidden)]
#[unstable(feature = "core", reason = "internal to format_args!")]
#[unstable(feature = "fmt_internals", reason = "internal to format_args!")]
pub fn from_usize(x: &usize) -> ArgumentV1 {
ArgumentV1::new(x, ArgumentV1::show_usize)
}
@ -201,7 +201,7 @@ impl<'a> Arguments<'a> {
/// When using the format_args!() macro, this function is used to generate the
/// Arguments structure.
#[doc(hidden)] #[inline]
#[unstable(feature = "core", reason = "internal to format_args!")]
#[unstable(feature = "fmt_internals", reason = "internal to format_args!")]
pub fn new_v1(pieces: &'a [&'a str],
args: &'a [ArgumentV1<'a>]) -> Arguments<'a> {
Arguments {
@ -218,7 +218,7 @@ impl<'a> Arguments<'a> {
/// created with `argumentusize`. However, failing to do so doesn't cause
/// unsafety, but will ignore invalid .
#[doc(hidden)] #[inline]
#[unstable(feature = "core", reason = "internal to format_args!")]
#[unstable(feature = "fmt_internals", reason = "internal to format_args!")]
pub fn new_v1_formatted(pieces: &'a [&'a str],
args: &'a [ArgumentV1<'a>],
fmt: &'a [rt::v1::Argument]) -> Arguments<'a> {
@ -742,19 +742,19 @@ impl<'a> Formatter<'a> {
pub fn flags(&self) -> u32 { self.flags }
/// Character used as 'fill' whenever there is alignment
#[unstable(feature = "core", reason = "method was just created")]
#[unstable(feature = "fmt_flags", reason = "method was just created")]
pub fn fill(&self) -> char { self.fill }
/// Flag indicating what form of alignment was requested
#[unstable(feature = "core", reason = "method was just created")]
#[unstable(feature = "fmt_flags", reason = "method was just created")]
pub fn align(&self) -> Alignment { self.align }
/// Optionally specified integer width that the output should be
#[unstable(feature = "core", reason = "method was just created")]
#[unstable(feature = "fmt_flags", reason = "method was just created")]
pub fn width(&self) -> Option<usize> { self.width }
/// Optionally specified precision for numeric types
#[unstable(feature = "core", reason = "method was just created")]
#[unstable(feature = "fmt_flags", reason = "method was just created")]
pub fn precision(&self) -> Option<usize> { self.precision }
/// Creates a `DebugStruct` builder designed to assist with creation of

View File

@ -127,7 +127,7 @@ radix! { UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x,
/// A radix with in the range of `2..36`.
#[derive(Clone, Copy, PartialEq)]
#[unstable(feature = "core",
#[unstable(feature = "fmt_radix",
reason = "may be renamed or move to a different module")]
pub struct Radix {
base: u8,
@ -152,7 +152,7 @@ impl GenericRadix for Radix {
}
/// A helper type for formatting radixes.
#[unstable(feature = "core",
#[unstable(feature = "fmt_radix",
reason = "may be renamed or move to a different module")]
#[derive(Copy, Clone)]
pub struct RadixFmt<T, R>(T, R);
@ -162,11 +162,11 @@ pub struct RadixFmt<T, R>(T, R);
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(fmt_radix)]
/// use std::fmt::radix;
/// assert_eq!(format!("{}", radix(55, 36)), "1j".to_string());
/// ```
#[unstable(feature = "core",
#[unstable(feature = "fmt_radix",
reason = "may be renamed or move to a different module")]
pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> {
RadixFmt(x, Radix::new(base))

View File

@ -14,8 +14,6 @@
//! These definitions are similar to their `ct` equivalents, but differ in that
//! these can be statically allocated and are slightly optimized for the runtime
#![unstable(feature = "core", reason = "internal to format_args!")]
#[derive(Copy, Clone)]
pub struct Argument {
pub position: Position,

View File

@ -16,7 +16,7 @@
//! # Examples
//!
//! ```rust
//! # #![feature(hash)]
//! # #![feature(hash_default)]
//! use std::hash::{hash, Hash, SipHasher};
//!
//! #[derive(Hash)]
@ -36,7 +36,7 @@
//! the trait `Hash`:
//!
//! ```rust
//! # #![feature(hash)]
//! # #![feature(hash_default)]
//! use std::hash::{hash, Hash, Hasher, SipHasher};
//!
//! struct Person {
@ -89,7 +89,8 @@ pub trait Hash {
fn hash<H: Hasher>(&self, state: &mut H);
/// Feeds a slice of this type into the state provided.
#[unstable(feature = "hash", reason = "module was recently redesigned")]
#[unstable(feature = "hash_slice",
reason = "module was recently redesigned")]
fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) where Self: Sized {
for piece in data {
piece.hash(state);
@ -110,29 +111,29 @@ pub trait Hasher {
/// Write a single `u8` into this hasher
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
fn write_u8(&mut self, i: u8) { self.write(&[i]) }
/// Write a single `u16` into this hasher.
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
fn write_u16(&mut self, i: u16) {
self.write(&unsafe { mem::transmute::<_, [u8; 2]>(i) })
}
/// Write a single `u32` into this hasher.
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
fn write_u32(&mut self, i: u32) {
self.write(&unsafe { mem::transmute::<_, [u8; 4]>(i) })
}
/// Write a single `u64` into this hasher.
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
fn write_u64(&mut self, i: u64) {
self.write(&unsafe { mem::transmute::<_, [u8; 8]>(i) })
}
/// Write a single `usize` into this hasher.
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
fn write_usize(&mut self, i: usize) {
if cfg!(target_pointer_width = "32") {
self.write_u32(i as u32)
@ -143,23 +144,23 @@ pub trait Hasher {
/// Write a single `i8` into this hasher.
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
fn write_i8(&mut self, i: i8) { self.write_u8(i as u8) }
/// Write a single `i16` into this hasher.
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
fn write_i16(&mut self, i: i16) { self.write_u16(i as u16) }
/// Write a single `i32` into this hasher.
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
fn write_i32(&mut self, i: i32) { self.write_u32(i as u32) }
/// Write a single `i64` into this hasher.
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
fn write_i64(&mut self, i: i64) { self.write_u64(i as u64) }
/// Write a single `isize` into this hasher.
#[inline]
#[unstable(feature = "hash", reason = "module was recently redesigned")]
#[unstable(feature = "hasher_write", reason = "module was recently redesigned")]
fn write_isize(&mut self, i: isize) { self.write_usize(i as usize) }
}
@ -167,7 +168,9 @@ pub trait Hasher {
///
/// The specified value will be hashed with this hasher and then the resulting
/// hash will be returned.
#[unstable(feature = "hash", reason = "module was recently redesigned")]
#[unstable(feature = "hash_default",
reason = "not the most ergonomic interface unless `H` is defaulted \
to SipHasher, but perhaps not ready to commit to that")]
pub fn hash<T: Hash, H: Hasher + Default>(value: &T) -> u64 {
let mut h: H = Default::default();
value.hash(&mut h);

View File

@ -39,7 +39,10 @@
//! guaranteed to happen in order. This is the standard mode for working
//! with atomic types and is equivalent to Java's `volatile`.
#![unstable(feature = "core")]
#![unstable(feature = "core_intrinsics",
reason = "intrinsics are unlikely to ever be stabilized, instead \
they should be used through stabilized interfaces \
in the rest of the standard library")]
#![allow(missing_docs)]
use marker::Sized;
@ -141,10 +144,10 @@ extern "rust-intrinsic" {
/// A compiler-only memory barrier.
///
/// Memory accesses will never be reordered across this barrier by the compiler,
/// but no instructions will be emitted for it. This is appropriate for operations
/// on the same thread that may be preempted, such as when interacting with signal
/// handlers.
/// Memory accesses will never be reordered across this barrier by the
/// compiler, but no instructions will be emitted for it. This is
/// appropriate for operations on the same thread that may be preempted,
/// such as when interacting with signal handlers.
pub fn atomic_singlethreadfence();
pub fn atomic_singlethreadfence_acq();
pub fn atomic_singlethreadfence_rel();

View File

@ -51,8 +51,8 @@
//! }
//! ```
//!
//! Because `Iterator`s implement `IntoIterator`, this `for` loop syntax can be applied to any
//! iterator over any type.
//! Because `Iterator`s implement `IntoIterator`, this `for` loop syntax can be
//! applied to any iterator over any type.
#![stable(feature = "rust1", since = "1.0.0")]
@ -822,7 +822,7 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(iter_min_max)]
/// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax};
///
/// let a: [i32; 0] = [];
@ -837,7 +837,9 @@ pub trait Iterator {
/// let a = [1, 1, 1, 1];
/// assert_eq!(a.iter().min_max(), MinMax(&1, &1));
/// ```
#[unstable(feature = "core", reason = "return type may change")]
#[unstable(feature = "iter_min_max",
reason = "return type may change or may wish to have a closure \
based version as well")]
fn min_max(mut self) -> MinMaxResult<Self::Item> where Self: Sized, Self::Item: Ord
{
let (mut min, mut max) = match self.next() {
@ -892,12 +894,12 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(iter_cmp)]
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10);
/// ```
#[inline]
#[unstable(feature = "core",
#[unstable(feature = "iter_cmp",
reason = "may want to produce an Ordering directly; see #15311")]
fn max_by<B: Ord, F>(self, f: F) -> Option<Self::Item> where
Self: Sized,
@ -920,12 +922,12 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(iter_cmp)]
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0);
/// ```
#[inline]
#[unstable(feature = "core",
#[unstable(feature = "iter_cmp",
reason = "may want to produce an Ordering directly; see #15311")]
fn min_by<B: Ord, F>(self, f: F) -> Option<Self::Item> where
Self: Sized,
@ -1041,6 +1043,8 @@ pub trait Iterator {
/// Use an iterator to reverse a container in place.
#[unstable(feature = "core",
reason = "uncertain about placement or widespread use")]
#[deprecated(since = "1.2.0",
reason = "not performant enough to justify inclusion")]
fn reverse_in_place<'a, T: 'a>(&mut self) where
Self: Sized + Iterator<Item=&'a mut T> + DoubleEndedIterator
{
@ -1057,12 +1061,12 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(iter_arith)]
/// let a = [1, 2, 3, 4, 5];
/// let it = a.iter();
/// assert_eq!(it.sum::<i32>(), 15);
/// ```
#[unstable(feature="core")]
#[unstable(feature="iter_arith", reason = "bounds recently changed")]
fn sum<S=<Self as Iterator>::Item>(self) -> S where
S: Add<Self::Item, Output=S> + Zero,
Self: Sized,
@ -1075,7 +1079,7 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(iter_arith)]
/// fn factorial(n: u32) -> u32 {
/// (1..).take_while(|&i| i <= n).product()
/// }
@ -1083,7 +1087,7 @@ pub trait Iterator {
/// assert_eq!(factorial(1), 1);
/// assert_eq!(factorial(5), 120);
/// ```
#[unstable(feature="core")]
#[unstable(feature="iter_arith", reason = "bounds recently changed")]
fn product<P=<Self as Iterator>::Item>(self) -> P where
P: Mul<Self::Item, Output=P> + One,
Self: Sized,
@ -1223,9 +1227,14 @@ impl<'a, I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for &'a mut I {
/// `DoubleEndedIterator`. Calling `next()` or `next_back()` on a
/// `RandomAccessIterator` reduces the indexable range accordingly. That is,
/// `it.idx(1)` will become `it.idx(0)` after `it.next()` is called.
#[unstable(feature = "core",
#[unstable(feature = "iter_idx",
reason = "not widely used, may be better decomposed into Index \
and ExactSizeIterator")]
#[deprecated(since = "1.2.0",
reason = "trait has not proven itself as a widely useful \
abstraction for iterators, and more time may be needed \
for iteration on the design")]
#[allow(deprecated)]
pub trait RandomAccessIterator: Iterator {
/// Returns the number of indexable elements. At most `std::usize::MAX`
/// elements are indexable, even if the iterator represents a longer range.
@ -1304,7 +1313,8 @@ impl<I> DoubleEndedIterator for Rev<I> where I: DoubleEndedIterator {
fn next_back(&mut self) -> Option<<I as Iterator>::Item> { self.iter.next() }
}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<I> RandomAccessIterator for Rev<I>
where I: DoubleEndedIterator + RandomAccessIterator
{
@ -1324,7 +1334,7 @@ impl<I> RandomAccessIterator for Rev<I>
/// `MinMaxResult` is an enum returned by `min_max`. See `Iterator::min_max` for
/// more detail.
#[derive(Clone, PartialEq, Debug)]
#[unstable(feature = "core",
#[unstable(feature = "iter_min_max",
reason = "unclear whether such a fine-grained result is widely useful")]
pub enum MinMaxResult<T> {
/// Empty iterator
@ -1338,6 +1348,7 @@ pub enum MinMaxResult<T> {
MinMax(T, T)
}
#[unstable(feature = "iter_min_max", reason = "type is unstable")]
impl<T: Clone> MinMaxResult<T> {
/// `into_option` creates an `Option` of type `(T,T)`. The returned `Option`
/// has variant `None` if and only if the `MinMaxResult` has variant
@ -1348,7 +1359,7 @@ impl<T: Clone> MinMaxResult<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(iter_min_max)]
/// use std::iter::MinMaxResult::{self, NoElements, OneElement, MinMax};
///
/// let r: MinMaxResult<i32> = NoElements;
@ -1360,7 +1371,6 @@ impl<T: Clone> MinMaxResult<T> {
/// let r = MinMax(1, 2);
/// assert_eq!(r.into_option(), Some((1, 2)));
/// ```
#[unstable(feature = "core", reason = "type is unstable")]
pub fn into_option(self) -> Option<(T,T)> {
match self {
NoElements => None,
@ -1407,7 +1417,8 @@ impl<'a, I, T: 'a> ExactSizeIterator for Cloned<I>
where I: ExactSizeIterator<Item=&'a T>, T: Clone
{}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<'a, I, T: 'a> RandomAccessIterator for Cloned<I>
where I: RandomAccessIterator<Item=&'a T>, T: Clone
{
@ -1454,7 +1465,8 @@ impl<I> Iterator for Cycle<I> where I: Clone + Iterator {
}
}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<I> RandomAccessIterator for Cycle<I> where
I: Clone + RandomAccessIterator,
{
@ -1568,7 +1580,8 @@ impl<A, B> DoubleEndedIterator for Chain<A, B> where
}
}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<A, B> RandomAccessIterator for Chain<A, B> where
A: RandomAccessIterator,
B: RandomAccessIterator<Item = A::Item>,
@ -1656,7 +1669,8 @@ impl<A, B> DoubleEndedIterator for Zip<A, B> where
}
}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<A, B> RandomAccessIterator for Zip<A, B> where
A: RandomAccessIterator,
B: RandomAccessIterator
@ -1710,7 +1724,8 @@ impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for Map<I, F> where
}
}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<B, I: RandomAccessIterator, F> RandomAccessIterator for Map<I, F> where
F: FnMut(I::Item) -> B,
{
@ -1884,7 +1899,8 @@ impl<I> DoubleEndedIterator for Enumerate<I> where
}
}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<I> RandomAccessIterator for Enumerate<I> where I: RandomAccessIterator {
#[inline]
fn indexable(&self) -> usize {
@ -2134,7 +2150,8 @@ impl<I> Iterator for Skip<I> where I: Iterator {
}
}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<I> RandomAccessIterator for Skip<I> where I: RandomAccessIterator{
#[inline]
fn indexable(&self) -> usize {
@ -2206,7 +2223,8 @@ impl<I> Iterator for Take<I> where I: Iterator{
}
}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<I> RandomAccessIterator for Take<I> where I: RandomAccessIterator{
#[inline]
fn indexable(&self) -> usize {
@ -2236,7 +2254,8 @@ pub struct Scan<I, St, F> {
f: F,
/// The current internal state to be passed to the closure next.
#[unstable(feature = "core")]
#[unstable(feature = "scan_state",
reason = "public fields are otherwise rare in the stdlib")]
pub state: St,
}
@ -2406,7 +2425,8 @@ impl<I> DoubleEndedIterator for Fuse<I> where I: DoubleEndedIterator {
}
// Allow RandomAccessIterators to be fused without affecting random-access behavior
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<I> RandomAccessIterator for Fuse<I> where I: RandomAccessIterator {
#[inline]
fn indexable(&self) -> usize {
@ -2427,7 +2447,7 @@ impl<I> Fuse<I> {
/// `.next_back()` will call the underlying iterator again even if it
/// previously returned `None`.
#[inline]
#[unstable(feature = "core", reason = "seems marginal")]
#[unstable(feature = "iter_reset_fuse", reason = "seems marginal")]
pub fn reset_fuse(&mut self) {
self.done = false
}
@ -2481,7 +2501,8 @@ impl<I: DoubleEndedIterator, F> DoubleEndedIterator for Inspect<I, F>
}
}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<I: RandomAccessIterator, F> RandomAccessIterator for Inspect<I, F>
where F: FnMut(&I::Item),
{
@ -2504,7 +2525,7 @@ impl<I: RandomAccessIterator, F> RandomAccessIterator for Inspect<I, F>
/// An iterator that yields sequential Fibonacci numbers, and stops on overflow.
///
/// ```
/// #![feature(core)]
/// #![feature(iter_unfold)]
/// use std::iter::Unfold;
///
/// // This iterator will yield up to the last Fibonacci number before the max
@ -2531,16 +2552,24 @@ impl<I: RandomAccessIterator, F> RandomAccessIterator for Inspect<I, F>
/// println!("{}", i);
/// }
/// ```
#[unstable(feature = "core")]
#[unstable(feature = "iter_unfold")]
#[derive(Clone)]
#[deprecated(since = "1.2.0",
reason = "has gained enough traction to retain its position \
in the standard library")]
#[allow(deprecated)]
pub struct Unfold<St, F> {
f: F,
/// Internal state that will be passed to the closure on the next iteration
#[unstable(feature = "core")]
#[unstable(feature = "iter_unfold")]
pub state: St,
}
#[unstable(feature = "core")]
#[unstable(feature = "iter_unfold")]
#[deprecated(since = "1.2.0",
reason = "has gained enough traction to retain its position \
in the standard library")]
#[allow(deprecated)]
impl<A, St, F> Unfold<St, F> where F: FnMut(&mut St) -> Option<A> {
/// Creates a new iterator with the specified closure as the "iterator
/// function" and an initial state to eventually pass to the closure
@ -2554,6 +2583,7 @@ impl<A, St, F> Unfold<St, F> where F: FnMut(&mut St) -> Option<A> {
}
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl<A, St, F> Iterator for Unfold<St, F> where F: FnMut(&mut St) -> Option<A> {
type Item = A;
@ -2767,7 +2797,7 @@ impl<A> Iterator for StepBy<A, RangeFrom<A>> where
/// An iterator over the range [start, stop]
#[derive(Clone)]
#[unstable(feature = "core",
#[unstable(feature = "range_inclusive",
reason = "likely to be replaced by range notation and adapters")]
pub struct RangeInclusive<A> {
range: ops::Range<A>,
@ -2776,7 +2806,7 @@ pub struct RangeInclusive<A> {
/// Returns an iterator over the range [start, stop].
#[inline]
#[unstable(feature = "core",
#[unstable(feature = "range_inclusive",
reason = "likely to be replaced by range notation and adapters")]
pub fn range_inclusive<A>(start: A, stop: A) -> RangeInclusive<A>
where A: Step + One + Clone
@ -2787,7 +2817,7 @@ pub fn range_inclusive<A>(start: A, stop: A) -> RangeInclusive<A>
}
}
#[unstable(feature = "core",
#[unstable(feature = "range_inclusive",
reason = "likely to be replaced by range notation and adapters")]
impl<A> Iterator for RangeInclusive<A> where
A: PartialEq + Step + One + Clone,
@ -2820,7 +2850,7 @@ impl<A> Iterator for RangeInclusive<A> where
}
}
#[unstable(feature = "core",
#[unstable(feature = "range_inclusive",
reason = "likely to be replaced by range notation and adapters")]
impl<A> DoubleEndedIterator for RangeInclusive<A> where
A: PartialEq + Step + One + Clone,
@ -2962,7 +2992,7 @@ impl<A: Clone> Iterator for Repeat<A> {
type Item = A;
#[inline]
fn next(&mut self) -> Option<A> { self.idx(0) }
fn next(&mut self) -> Option<A> { Some(self.element.clone()) }
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) { (usize::MAX, None) }
}
@ -2970,10 +3000,11 @@ impl<A: Clone> Iterator for Repeat<A> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<A: Clone> DoubleEndedIterator for Repeat<A> {
#[inline]
fn next_back(&mut self) -> Option<A> { self.idx(0) }
fn next_back(&mut self) -> Option<A> { Some(self.element.clone()) }
}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<A: Clone> RandomAccessIterator for Repeat<A> {
#[inline]
fn indexable(&self) -> usize { usize::MAX }
@ -2985,12 +3016,20 @@ type IterateState<T, F> = (F, Option<T>, bool);
/// An iterator that repeatedly applies a given function, starting
/// from a given seed value.
#[unstable(feature = "core")]
#[unstable(feature = "iter_iterate")]
#[deprecated(since = "1.2.0",
reason = "has gained enough traction to retain its position \
in the standard library")]
#[allow(deprecated)]
pub type Iterate<T, F> = Unfold<IterateState<T, F>, fn(&mut IterateState<T, F>) -> Option<T>>;
/// Creates a new iterator that produces an infinite sequence of
/// repeated applications of the given function `f`.
#[unstable(feature = "core")]
#[unstable(feature = "iter_iterate")]
#[deprecated(since = "1.2.0",
reason = "has gained enough traction to retain its position \
in the standard library")]
#[allow(deprecated)]
pub fn iterate<T, F>(seed: T, f: F) -> Iterate<T, F> where
T: Clone,
F: FnMut(T) -> T,
@ -3022,10 +3061,10 @@ pub fn repeat<T: Clone>(elt: T) -> Repeat<T> {
}
/// An iterator that yields nothing.
#[unstable(feature="iter_empty", reason = "new addition")]
#[stable(feature = "iter_empty", since = "1.2.0")]
pub struct Empty<T>(marker::PhantomData<T>);
#[unstable(feature="iter_empty", reason = "new addition")]
#[stable(feature = "iter_empty", since = "1.2.0")]
impl<T> Iterator for Empty<T> {
type Item = T;
@ -3038,14 +3077,14 @@ impl<T> Iterator for Empty<T> {
}
}
#[unstable(feature="iter_empty", reason = "new addition")]
#[stable(feature = "iter_empty", since = "1.2.0")]
impl<T> DoubleEndedIterator for Empty<T> {
fn next_back(&mut self) -> Option<T> {
None
}
}
#[unstable(feature="iter_empty", reason = "new addition")]
#[stable(feature = "iter_empty", since = "1.2.0")]
impl<T> ExactSizeIterator for Empty<T> {
fn len(&self) -> usize {
0
@ -3054,7 +3093,7 @@ impl<T> ExactSizeIterator for Empty<T> {
// not #[derive] because that adds a Clone bound on T,
// which isn't necessary.
#[unstable(feature="iter_empty", reason = "new addition")]
#[stable(feature = "iter_empty", since = "1.2.0")]
impl<T> Clone for Empty<T> {
fn clone(&self) -> Empty<T> {
Empty(marker::PhantomData)
@ -3063,7 +3102,7 @@ impl<T> Clone for Empty<T> {
// not #[derive] because that adds a Default bound on T,
// which isn't necessary.
#[unstable(feature="iter_empty", reason = "new addition")]
#[stable(feature = "iter_empty", since = "1.2.0")]
impl<T> Default for Empty<T> {
fn default() -> Empty<T> {
Empty(marker::PhantomData)
@ -3071,19 +3110,19 @@ impl<T> Default for Empty<T> {
}
/// Creates an iterator that yields nothing.
#[unstable(feature="iter_empty", reason = "new addition")]
#[stable(feature = "iter_empty", since = "1.2.0")]
pub fn empty<T>() -> Empty<T> {
Empty(marker::PhantomData)
}
/// An iterator that yields an element exactly once.
#[derive(Clone)]
#[unstable(feature="iter_once", reason = "new addition")]
#[stable(feature = "iter_once", since = "1.2.0")]
pub struct Once<T> {
inner: ::option::IntoIter<T>
}
#[unstable(feature="iter_once", reason = "new addition")]
#[stable(feature = "iter_once", since = "1.2.0")]
impl<T> Iterator for Once<T> {
type Item = T;
@ -3096,14 +3135,14 @@ impl<T> Iterator for Once<T> {
}
}
#[unstable(feature="iter_once", reason = "new addition")]
#[stable(feature = "iter_once", since = "1.2.0")]
impl<T> DoubleEndedIterator for Once<T> {
fn next_back(&mut self) -> Option<T> {
self.inner.next_back()
}
}
#[unstable(feature="iter_once", reason = "new addition")]
#[stable(feature = "iter_once", since = "1.2.0")]
impl<T> ExactSizeIterator for Once<T> {
fn len(&self) -> usize {
self.inner.len()
@ -3111,7 +3150,7 @@ impl<T> ExactSizeIterator for Once<T> {
}
/// Creates an iterator that yields an element exactly once.
#[unstable(feature="iter_once", reason = "new addition")]
#[stable(feature = "iter_once", since = "1.2.0")]
pub fn once<T>(value: T) -> Once<T> {
Once { inner: Some(value).into_iter() }
}
@ -3123,7 +3162,7 @@ pub fn once<T>(value: T) -> Once<T> {
///
/// If two sequences are equal up until the point where one ends,
/// the shorter sequence compares less.
#[unstable(feature = "core", reason = "needs review and revision")]
#[unstable(feature = "iter_order", reason = "needs review and revision")]
pub mod order {
use cmp;
use cmp::{Eq, Ord, PartialOrd, PartialEq};

View File

@ -49,7 +49,9 @@
// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)
#![cfg_attr(stage0, feature(custom_attribute))]
#![crate_name = "core"]
#![unstable(feature = "core")]
#![unstable(feature = "core",
reason = "the libcore library has not yet been scrutinized for \
stabilization in terms of structure and naming")]
#![staged_api]
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@ -63,7 +65,8 @@
#![allow(raw_pointer_derive)]
#![deny(missing_docs)]
#![feature(intrinsics, lang_items)]
#![feature(intrinsics)]
#![feature(lang_items)]
#![feature(on_unimplemented)]
#![feature(simd)]
#![feature(staged_api)]
@ -75,6 +78,7 @@
#![feature(reflect)]
#![feature(custom_attribute)]
#![feature(const_fn)]
#![feature(allow_internal_unstable)]
#[macro_use]
mod macros;

View File

@ -10,6 +10,7 @@
/// Entry point of thread panic, for details, see std::macros
#[macro_export]
#[allow_internal_unstable]
macro_rules! panic {
() => (
panic!("explicit panic")

View File

@ -54,7 +54,7 @@ pub trait Sized {
}
/// Types that can be "unsized" to a dynamically sized type.
#[unstable(feature = "core")]
#[unstable(feature = "unsize")]
#[lang="unsize"]
pub trait Unsize<T> {
// Empty.
@ -223,7 +223,10 @@ impl<T> !Sync for *mut T { }
/// ensure that they are never copied, even if they lack a destructor.
#[unstable(feature = "core",
reason = "likely to change with new variance strategy")]
#[deprecated(since = "1.2.0",
reason = "structs are by default not copyable")]
#[lang = "no_copy_bound"]
#[allow(deprecated)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct NoCopy;
@ -385,7 +388,7 @@ mod impls {
/// that function. Here is an example:
///
/// ```
/// #![feature(core)]
/// #![feature(reflect_marker)]
/// use std::marker::Reflect;
/// use std::any::Any;
/// fn foo<T:Reflect+'static>(x: &T) {
@ -410,7 +413,8 @@ mod impls {
///
/// [1]: http://en.wikipedia.org/wiki/Parametricity
#[rustc_reflect_like]
#[unstable(feature = "core", reason = "requires RFC and more experience")]
#[unstable(feature = "reflect_marker",
reason = "requires RFC and more experience")]
#[allow(deprecated)]
#[rustc_on_unimplemented = "`{Self}` does not implement `Any`; \
ensure all type parameters are bounded by `Any`"]

View File

@ -459,9 +459,13 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
/// Transforms lifetime of the second pointer to match the first.
#[inline]
#[unstable(feature = "core",
#[unstable(feature = "copy_lifetime",
reason = "this function may be removed in the future due to its \
questionable utility")]
#[deprecated(since = "1.2.0",
reason = "unclear that this function buys more safety and \
lifetimes are generally not handled as such in unsafe \
code today")]
pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S,
ptr: &T) -> &'a T {
transmute(ptr)
@ -469,9 +473,13 @@ pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S,
/// Transforms lifetime of the second mutable pointer to match the first.
#[inline]
#[unstable(feature = "core",
#[unstable(feature = "copy_lifetime",
reason = "this function may be removed in the future due to its \
questionable utility")]
#[deprecated(since = "1.2.0",
reason = "unclear that this function buys more safety and \
lifetimes are generally not handled as such in unsafe \
code today")]
pub unsafe fn copy_mut_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S,
ptr: &mut T)
-> &'a mut T

View File

@ -9,6 +9,8 @@
// except according to those terms.
//! Exposes the NonZero lang item which provides optimization hints.
#![unstable(feature = "nonzero",
reason = "needs an RFC to flesh out the design")]
use marker::Sized;
use ops::{CoerceUnsized, Deref};
@ -33,7 +35,6 @@ unsafe impl Zeroable for u64 {}
/// NULL or 0 that might allow certain optimizations.
#[lang = "non_zero"]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)]
#[unstable(feature = "core")]
pub struct NonZero<T: Zeroable>(T);
impl<T: Zeroable> NonZero<T> {

View File

@ -71,7 +71,9 @@ pub mod consts {
pub const PI: f32 = 3.14159265358979323846264338327950288_f32;
/// pi * 2.0
#[unstable(feature = "core", reason = "unclear naming convention/usefulness")]
#[unstable(feature = "float_consts",
reason = "unclear naming convention/usefulness")]
#[deprecated(since = "1.2.0", reason = "unclear on usefulness")]
pub const PI_2: f32 = 6.28318530717958647692528676655900576_f32;
/// pi/2.0
@ -135,7 +137,6 @@ pub mod consts {
pub const LN_10: f32 = 2.30258509299404568401799145468436421_f32;
}
#[unstable(feature = "core", reason = "trait is unstable")]
impl Float for f32 {
#[inline]
fn nan() -> f32 { NAN }

View File

@ -71,7 +71,9 @@ pub mod consts {
pub const PI: f64 = 3.14159265358979323846264338327950288_f64;
/// pi * 2.0
#[unstable(feature = "core", reason = "unclear naming convention/usefulness")]
#[unstable(feature = "float_consts",
reason = "unclear naming convention/usefulness")]
#[deprecated(since = "1.2.0", reason = "unclear on usefulness")]
pub const PI_2: f64 = 6.28318530717958647692528676655900576_f64;
/// pi/2.0
@ -135,7 +137,6 @@ pub mod consts {
pub const LN_10: f64 = 2.30258509299404568401799145468436421_f64;
}
#[unstable(feature = "core", reason = "trait is unstable")]
impl Float for f64 {
#[inline]
fn nan() -> f64 { NAN }

View File

@ -126,6 +126,8 @@ functions.
// while this is extensively documented, this is in principle private which is
// only made public for testing. do not expose us.
#![doc(hidden)]
#![unstable(feature = "flt2dec",
reason = "internal routines only exposed for testing")]
use prelude::*;
use i16;

View File

@ -14,11 +14,13 @@ macro_rules! int_module { ($T:ty, $bits:expr) => (
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
// calling the `mem::size_of` function.
#[unstable(feature = "core")]
#[unstable(feature = "num_bits_bytes",
reason = "may want to be an associated function")]
pub const BITS : usize = $bits;
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of
// calling the `mem::size_of` function.
#[unstable(feature = "core")]
#[unstable(feature = "num_bits_bytes",
reason = "may want to be an associated function")]
pub const BYTES : usize = ($bits / 8);
// FIXME(#11621): Should be deprecated once CTFE is implemented in favour of

View File

@ -41,10 +41,7 @@ use str::{FromStr, StrExt};
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug)]
pub struct Wrapping<T>(#[stable(feature = "rust1", since = "1.0.0")] pub T);
#[unstable(feature = "core", reason = "may be removed or relocated")]
pub mod wrapping;
#[unstable(feature = "core", reason = "internal routines only exposed for testing")]
pub mod flt2dec;
/// Types that have a "zero" value.
@ -471,7 +468,7 @@ macro_rules! int_impl {
/// to `-MIN`, a positive value that is too large to represent
/// in the type. In such a case, this function returns `MIN`
/// itself..
#[unstable(feature = "core", since = "1.0.0")]
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_div(self, rhs: Self) -> Self {
self.overflowing_div(rhs).0
@ -484,7 +481,7 @@ macro_rules! int_impl {
/// implementation artifacts make `x % y` illegal for `MIN /
/// -1` on a signed type illegal (where `MIN` is the negative
/// minimal value). In such a case, this function returns `0`.
#[unstable(feature = "core", since = "1.0.0")]
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_rem(self, rhs: Self) -> Self {
self.overflowing_rem(rhs).0
@ -498,7 +495,7 @@ macro_rules! int_impl {
/// negative minimal value for the type); this is a positive
/// value that is too large to represent in the type. In such
/// a case, this function returns `MIN` itself.
#[unstable(feature = "core", since = "1.0.0")]
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_neg(self) -> Self {
self.overflowing_neg().0
@ -507,7 +504,7 @@ macro_rules! int_impl {
/// Panic-free bitwise shift-left; yields `self << mask(rhs)`,
/// where `mask` removes any high-order bits of `rhs` that
/// would cause the shift to exceed the bitwidth of the type.
#[unstable(feature = "core", since = "1.0.0")]
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_shl(self, rhs: u32) -> Self {
self.overflowing_shl(rhs).0
@ -516,7 +513,7 @@ macro_rules! int_impl {
/// Panic-free bitwise shift-left; yields `self >> mask(rhs)`,
/// where `mask` removes any high-order bits of `rhs` that
/// would cause the shift to exceed the bitwidth of the type.
#[unstable(feature = "core", since = "1.0.0")]
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_shr(self, rhs: u32) -> Self {
self.overflowing_shr(rhs).0
@ -1041,7 +1038,7 @@ macro_rules! uint_impl {
/// to `-MIN`, a positive value that is too large to represent
/// in the type. In such a case, this function returns `MIN`
/// itself..
#[unstable(feature = "core", since = "1.0.0")]
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_div(self, rhs: Self) -> Self {
self.overflowing_div(rhs).0
@ -1054,7 +1051,7 @@ macro_rules! uint_impl {
/// implementation artifacts make `x % y` illegal for `MIN /
/// -1` on a signed type illegal (where `MIN` is the negative
/// minimal value). In such a case, this function returns `0`.
#[unstable(feature = "core", since = "1.0.0")]
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_rem(self, rhs: Self) -> Self {
self.overflowing_rem(rhs).0
@ -1068,7 +1065,7 @@ macro_rules! uint_impl {
/// negative minimal value for the type); this is a positive
/// value that is too large to represent in the type. In such
/// a case, this function returns `MIN` itself.
#[unstable(feature = "core", since = "1.0.0")]
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_neg(self) -> Self {
self.overflowing_neg().0
@ -1077,7 +1074,7 @@ macro_rules! uint_impl {
/// Panic-free bitwise shift-left; yields `self << mask(rhs)`,
/// where `mask` removes any high-order bits of `rhs` that
/// would cause the shift to exceed the bitwidth of the type.
#[unstable(feature = "core", since = "1.0.0")]
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_shl(self, rhs: u32) -> Self {
self.overflowing_shl(rhs).0
@ -1086,7 +1083,7 @@ macro_rules! uint_impl {
/// Panic-free bitwise shift-left; yields `self >> mask(rhs)`,
/// where `mask` removes any high-order bits of `rhs` that
/// would cause the shift to exceed the bitwidth of the type.
#[unstable(feature = "core", since = "1.0.0")]
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline(always)]
pub fn wrapping_shr(self, rhs: u32) -> Self {
self.overflowing_shr(rhs).0
@ -1262,6 +1259,8 @@ pub enum FpCategory {
/// A built-in floating point number.
#[doc(hidden)]
#[unstable(feature = "core_float",
reason = "stable interface is via `impl f{32,64}` in later crates")]
pub trait Float {
/// Returns the NaN value.
fn nan() -> Self;
@ -1512,8 +1511,11 @@ enum IntErrorKind {
}
impl ParseIntError {
#[unstable(feature = "core", reason = "available through Error trait")]
pub fn description(&self) -> &str {
#[unstable(feature = "int_error_internals",
reason = "available through Error trait and this method should \
not be exposed publicly")]
#[doc(hidden)]
pub fn __description(&self) -> &str {
match self.kind {
IntErrorKind::Empty => "cannot parse integer from empty string",
IntErrorKind::InvalidDigit => "invalid digit found in string",
@ -1526,7 +1528,7 @@ impl ParseIntError {
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Display for ParseIntError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.description().fmt(f)
self.__description().fmt(f)
}
}
@ -1535,10 +1537,15 @@ impl fmt::Display for ParseIntError {
#[stable(feature = "rust1", since = "1.0.0")]
pub struct ParseFloatError {
#[doc(hidden)]
#[unstable(feature = "float_error_internals",
reason = "should not be exposed publicly")]
pub __kind: FloatErrorKind
}
#[derive(Debug, Clone, PartialEq)]
#[unstable(feature = "float_error_internals",
reason = "should not be exposed publicly")]
#[doc(hidden)]
pub enum FloatErrorKind {
Empty,
Invalid,

View File

@ -12,9 +12,11 @@
macro_rules! uint_module { ($T:ty, $T_SIGNED:ty, $bits:expr) => (
#[unstable(feature = "core")]
#[unstable(feature = "num_bits_bytes",
reason = "may want to be an associated function")]
pub const BITS : usize = $bits;
#[unstable(feature = "core")]
#[unstable(feature = "num_bits_bytes",
reason = "may want to be an associated function")]
pub const BYTES : usize = ($bits / 8);
#[stable(feature = "rust1", since = "1.0.0")]

View File

@ -10,6 +10,7 @@
#![allow(missing_docs)]
#![allow(deprecated)]
#![unstable(feature = "wrapping", reason = "may be removed or relocated")]
use super::Wrapping;
@ -30,7 +31,6 @@ use intrinsics::{i64_mul_with_overflow, u64_mul_with_overflow};
use ::{i8,i16,i32,i64};
#[unstable(feature = "core", reason = "may be removed, renamed, or relocated")]
pub trait OverflowingOps {
fn overflowing_add(self, rhs: Self) -> (Self, bool);
fn overflowing_sub(self, rhs: Self) -> (Self, bool);

View File

@ -29,8 +29,8 @@
//!
//! # Examples
//!
//! This example creates a `Point` struct that implements `Add` and `Sub`, and then
//! demonstrates adding and subtracting two `Point`s.
//! This example creates a `Point` struct that implements `Add` and `Sub`, and
//! then demonstrates adding and subtracting two `Point`s.
//!
//! ```rust
//! use std::ops::{Add, Sub};
@ -62,21 +62,21 @@
//! }
//! ```
//!
//! See the documentation for each trait for a minimum implementation that prints
//! something to the screen.
//! See the documentation for each trait for a minimum implementation that
//! prints something to the screen.
#![stable(feature = "rust1", since = "1.0.0")]
use marker::{Sized, Unsize};
use fmt;
/// The `Drop` trait is used to run some code when a value goes out of scope. This
/// is sometimes called a 'destructor'.
/// The `Drop` trait is used to run some code when a value goes out of scope.
/// This is sometimes called a 'destructor'.
///
/// # Examples
///
/// A trivial implementation of `Drop`. The `drop` method is called when `_x` goes
/// out of scope, and therefore `main` prints `Dropping!`.
/// A trivial implementation of `Drop`. The `drop` method is called when `_x`
/// goes out of scope, and therefore `main` prints `Dropping!`.
///
/// ```
/// struct HasDrop;
@ -103,8 +103,7 @@ pub trait Drop {
// based on "op T" where T is expected to be `Copy`able
macro_rules! forward_ref_unop {
(impl $imp:ident, $method:ident for $t:ty) => {
#[unstable(feature = "core",
reason = "recently added, waiting for dust to settle")]
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> $imp for &'a $t {
type Output = <$t as $imp>::Output;
@ -120,8 +119,7 @@ macro_rules! forward_ref_unop {
// based on "T op U" where T and U are expected to be `Copy`able
macro_rules! forward_ref_binop {
(impl $imp:ident, $method:ident for $t:ty, $u:ty) => {
#[unstable(feature = "core",
reason = "recently added, waiting for dust to settle")]
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> $imp<$u> for &'a $t {
type Output = <$t as $imp<$u>>::Output;
@ -131,8 +129,7 @@ macro_rules! forward_ref_binop {
}
}
#[unstable(feature = "core",
reason = "recently added, waiting for dust to settle")]
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> $imp<&'a $u> for $t {
type Output = <$t as $imp<$u>>::Output;
@ -142,8 +139,7 @@ macro_rules! forward_ref_binop {
}
}
#[unstable(feature = "core",
reason = "recently added, waiting for dust to settle")]
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, 'b> $imp<&'a $u> for &'b $t {
type Output = <$t as $imp<$u>>::Output;
@ -1210,7 +1206,7 @@ mod impls {
/// Trait that indicates that this is a pointer or a wrapper for one,
/// where unsizing can be performed on the pointee.
#[unstable(feature = "core")]
#[unstable(feature = "coerce_unsized")]
#[lang="coerce_unsized"]
pub trait CoerceUnsized<T> {
// Empty.

View File

@ -274,7 +274,7 @@ impl<T> Option<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(as_slice)]
/// let mut x = Some("Diamonds");
/// {
/// let v = x.as_mut_slice();
@ -285,7 +285,7 @@ impl<T> Option<T> {
/// assert_eq!(x, Some("Dirt"));
/// ```
#[inline]
#[unstable(feature = "core",
#[unstable(feature = "as_slice",
reason = "waiting for mut conventions")]
pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] {
match *self {

View File

@ -29,6 +29,9 @@
//! library, but the location of this may change over time.
#![allow(dead_code, missing_docs)]
#![unstable(feature = "core_panic",
reason = "internal details of the implementation of the `panic!` \
and related macros")]
use fmt;

View File

@ -24,6 +24,10 @@
//! use core::prelude::*;
//! ```
#![unstable(feature = "core_prelude",
reason = "the libcore prelude has not been scrutinized and \
stabilized yet")]
// Reexported core operators
pub use marker::{Copy, Send, Sized, Sync};
pub use ops::{Drop, Fn, FnMut, FnOnce};
@ -32,7 +36,6 @@ pub use ops::{Drop, Fn, FnMut, FnOnce};
pub use mem::drop;
// Reexported types and traits
pub use char::CharExt;
pub use clone::Clone;
pub use cmp::{PartialEq, PartialOrd, Eq, Ord};

View File

@ -49,7 +49,7 @@
//! the raw pointer. It doesn't destroy `T` or deallocate any memory.
//!
//! ```
//! # #![feature(alloc)]
//! # #![feature(box_raw)]
//! use std::boxed;
//!
//! unsafe {
@ -204,7 +204,7 @@ pub unsafe fn read<T>(src: *const T) -> T {
///
/// This is unsafe for the same reasons that `read` is unsafe.
#[inline(always)]
#[unstable(feature = "core",
#[unstable(feature = "read_and_zero",
reason = "may play a larger role in std::ptr future extensions")]
pub unsafe fn read_and_zero<T>(dest: *mut T) -> T {
// Copy the data out from `dest`:
@ -219,7 +219,7 @@ pub unsafe fn read_and_zero<T>(dest: *mut T) -> T {
/// Variant of read_and_zero that writes the specific drop-flag byte
/// (which may be more appropriate than zero).
#[inline(always)]
#[unstable(feature = "core",
#[unstable(feature = "filling_drop",
reason = "may play a larger role in std::ptr future extensions")]
pub unsafe fn read_and_drop<T>(dest: *mut T) -> T {
// Copy the data out from `dest`:
@ -267,9 +267,10 @@ impl<T: ?Sized> *const T {
/// null-safety, it is important to note that this is still an unsafe
/// operation because the returned value could be pointing to invalid
/// memory.
#[unstable(feature = "core",
reason = "Option is not clearly the right return type, and we may want \
to tie the return lifetime to a borrow of the raw pointer")]
#[unstable(feature = "ptr_as_ref",
reason = "Option is not clearly the right return type, and we \
may want to tie the return lifetime to a borrow of \
the raw pointer")]
#[inline]
pub unsafe fn as_ref<'a>(&self) -> Option<&'a T> where T: Sized {
if self.is_null() {
@ -314,9 +315,10 @@ impl<T: ?Sized> *mut T {
/// null-safety, it is important to note that this is still an unsafe
/// operation because the returned value could be pointing to invalid
/// memory.
#[unstable(feature = "core",
reason = "Option is not clearly the right return type, and we may want \
to tie the return lifetime to a borrow of the raw pointer")]
#[unstable(feature = "ptr_as_ref",
reason = "Option is not clearly the right return type, and we \
may want to tie the return lifetime to a borrow of \
the raw pointer")]
#[inline]
pub unsafe fn as_ref<'a>(&self) -> Option<&'a T> where T: Sized {
if self.is_null() {
@ -347,7 +349,7 @@ impl<T: ?Sized> *mut T {
///
/// As with `as_ref`, this is unsafe because it cannot verify the validity
/// of the returned pointer.
#[unstable(feature = "core",
#[unstable(feature = "ptr_as_ref",
reason = "return value does not necessarily convey all possible \
information")]
#[inline]
@ -507,7 +509,7 @@ impl<T: ?Sized> PartialOrd for *mut T {
/// modified without a unique path to the `Unique` reference. Useful
/// for building abstractions like `Vec<T>` or `Box<T>`, which
/// internally use raw pointers to manage the memory that they own.
#[unstable(feature = "unique")]
#[unstable(feature = "unique", reason = "needs an RFC to flesh out design")]
pub struct Unique<T: ?Sized> {
pointer: NonZero<*const T>,
_marker: PhantomData<T>,
@ -527,21 +529,19 @@ unsafe impl<T: Send + ?Sized> Send for Unique<T> { }
#[unstable(feature = "unique")]
unsafe impl<T: Sync + ?Sized> Sync for Unique<T> { }
#[unstable(feature = "unique")]
impl<T: ?Sized> Unique<T> {
/// Creates a new `Unique`.
#[unstable(feature = "unique")]
pub unsafe fn new(ptr: *mut T) -> Unique<T> {
Unique { pointer: NonZero::new(ptr), _marker: PhantomData }
}
/// Dereferences the content.
#[unstable(feature = "unique")]
pub unsafe fn get(&self) -> &T {
&**self.pointer
}
/// Mutably dereferences the content.
#[unstable(feature = "unique")]
pub unsafe fn get_mut(&mut self) -> &mut T {
&mut ***self
}

View File

@ -9,7 +9,7 @@
// except according to those terms.
#![allow(missing_docs)]
#![unstable(feature = "core")]
#![unstable(feature = "raw")]
//! Contains struct definitions for the layout of compiler built-in types.
//!
@ -49,7 +49,7 @@ use mem;
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(raw)]
/// use std::raw::{self, Repr};
///
/// let slice: &[u16] = &[1, 2, 3, 4];
@ -98,7 +98,7 @@ impl<T> Clone for Slice<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// # #![feature(raw)]
/// use std::mem;
/// use std::raw;
///

View File

@ -420,7 +420,7 @@ impl<T, E> Result<T, E> {
/// Converts from `Result<T, E>` to `&mut [T]` (without copying)
///
/// ```
/// # #![feature(core)]
/// # #![feature(as_slice)]
/// let mut x: Result<&str, u32> = Ok("Gold");
/// {
/// let v = x.as_mut_slice();
@ -434,7 +434,7 @@ impl<T, E> Result<T, E> {
/// assert!(x.as_mut_slice().is_empty());
/// ```
#[inline]
#[unstable(feature = "core",
#[unstable(feature = "as_slice",
reason = "waiting for mut conventions")]
pub fn as_mut_slice(&mut self) -> &mut [T] {
match *self {
@ -966,7 +966,11 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
/// If an `Err` is encountered, it is immediately returned.
/// Otherwise, the folded value is returned.
#[inline]
#[unstable(feature = "core")]
#[unstable(feature = "result_fold",
reason = "unclear if this function should exist")]
#[deprecated(since = "1.2.0",
reason = "has not seen enough usage to justify its position in \
the standard library")]
pub fn fold<T,
V,
E,

View File

@ -19,7 +19,7 @@
//! provided beyond this module.
//!
//! ```rust
//! # #![feature(core)]
//! # #![feature(core_simd)]
//! fn main() {
//! use std::simd::f32x4;
//! let a = f32x4(40.0, 41.0, 42.0, 43.0);
@ -33,10 +33,12 @@
//! These are all experimental. The interface may change entirely, without
//! warning.
#![unstable(feature = "core_simd",
reason = "needs an RFC to flesh out the design")]
#![allow(non_camel_case_types)]
#![allow(missing_docs)]
#[unstable(feature = "core")]
#[simd]
#[derive(Copy, Clone, Debug)]
#[repr(C)]
@ -45,26 +47,22 @@ pub struct i8x16(pub i8, pub i8, pub i8, pub i8,
pub i8, pub i8, pub i8, pub i8,
pub i8, pub i8, pub i8, pub i8);
#[unstable(feature = "core")]
#[simd]
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
pub i16, pub i16, pub i16, pub i16);
#[unstable(feature = "core")]
#[simd]
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
#[unstable(feature = "core")]
#[simd]
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct i64x2(pub i64, pub i64);
#[unstable(feature = "core")]
#[simd]
#[derive(Copy, Clone, Debug)]
#[repr(C)]
@ -73,32 +71,27 @@ pub struct u8x16(pub u8, pub u8, pub u8, pub u8,
pub u8, pub u8, pub u8, pub u8,
pub u8, pub u8, pub u8, pub u8);
#[unstable(feature = "core")]
#[simd]
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
pub u16, pub u16, pub u16, pub u16);
#[unstable(feature = "core")]
#[simd]
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
#[unstable(feature = "core")]
#[simd]
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct u64x2(pub u64, pub u64);
#[unstable(feature = "core")]
#[simd]
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
#[unstable(feature = "core")]
#[simd]
#[derive(Copy, Clone, Debug)]
#[repr(C)]

View File

@ -64,6 +64,8 @@ use raw::Slice as RawSlice;
/// Extension methods for slices.
#[allow(missing_docs)] // docs in libcollections
#[doc(hidden)]
#[unstable(feature = "core_slice_ext",
reason = "stable interface provided by `impl [T]` in later crates")]
pub trait SliceExt {
type Item;
@ -148,7 +150,6 @@ macro_rules! slice_ref {
}};
}
#[unstable(feature = "core")]
impl<T> SliceExt for [T] {
type Item = T;
@ -256,7 +257,6 @@ impl<T> SliceExt for [T] {
self.repr().data
}
#[unstable(feature = "core")]
fn binary_search_by<F>(&self, mut f: F) -> Result<usize, usize> where
F: FnMut(&T) -> Ordering
{
@ -437,12 +437,10 @@ impl<T> SliceExt for [T] {
m >= n && needle == &self[m-n..]
}
#[unstable(feature = "core")]
fn binary_search(&self, x: &T) -> Result<usize, usize> where T: Ord {
self.binary_search_by(|p| p.cmp(x))
}
#[unstable(feature = "core")]
fn next_permutation(&mut self) -> bool where T: Ord {
// These cases only have 1 permutation each, so we can't do anything.
if self.len() < 2 { return false; }
@ -473,7 +471,6 @@ impl<T> SliceExt for [T] {
true
}
#[unstable(feature = "core")]
fn prev_permutation(&mut self) -> bool where T: Ord {
// These cases only have 1 permutation each, so we can't do anything.
if self.len() < 2 { return false; }
@ -774,7 +771,7 @@ impl<'a, T> Iter<'a, T> {
///
/// This has the same lifetime as the original slice, and so the
/// iterator can continue to be used while this exists.
#[unstable(feature = "core")]
#[unstable(feature = "iter_to_slice")]
pub fn as_slice(&self) -> &'a [T] {
make_slice!(self.ptr, self.end)
}
@ -804,7 +801,8 @@ impl<'a, T> Clone for Iter<'a, T> {
fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } }
}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<'a, T> RandomAccessIterator for Iter<'a, T> {
#[inline]
fn indexable(&self) -> usize {
@ -842,7 +840,7 @@ impl<'a, T> IterMut<'a, T> {
/// to consume the iterator. Consider using the `Slice` and
/// `SliceMut` implementations for obtaining slices with more
/// restricted lifetimes that do not consume the iterator.
#[unstable(feature = "core")]
#[unstable(feature = "iter_to_slice")]
pub fn into_slice(self) -> &'a mut [T] {
make_mut_slice!(self.ptr, self.end)
}
@ -1176,7 +1174,8 @@ impl<'a, T> DoubleEndedIterator for Windows<'a, T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> ExactSizeIterator for Windows<'a, T> {}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<'a, T> RandomAccessIterator for Windows<'a, T> {
#[inline]
fn indexable(&self) -> usize {
@ -1263,7 +1262,8 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> ExactSizeIterator for Chunks<'a, T> {}
#[unstable(feature = "core", reason = "trait is experimental")]
#[unstable(feature = "iter_idx", reason = "trait is experimental")]
#[allow(deprecated)]
impl<'a, T> RandomAccessIterator for Chunks<'a, T> {
#[inline]
fn indexable(&self) -> usize {
@ -1349,7 +1349,7 @@ impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {}
//
/// Converts a pointer to A into a slice of length 1 (without copying).
#[unstable(feature = "core")]
#[unstable(feature = "ref_slice")]
pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] {
unsafe {
from_raw_parts(s, 1)
@ -1357,7 +1357,7 @@ pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] {
}
/// Converts a pointer to A into a slice of length 1 (without copying).
#[unstable(feature = "core")]
#[unstable(feature = "ref_slice")]
pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] {
unsafe {
from_raw_parts_mut(s, 1)
@ -1415,7 +1415,7 @@ pub unsafe fn from_raw_parts_mut<'a, T>(p: *mut T, len: usize) -> &'a mut [T] {
//
/// Operations on `[u8]`.
#[unstable(feature = "core", reason = "needs review")]
#[unstable(feature = "slice_bytes", reason = "needs review")]
pub mod bytes {
use ptr;
use slice::SliceExt;
@ -1503,7 +1503,11 @@ impl<T: PartialOrd> PartialOrd for [T] {
}
/// Extension methods for slices containing integers.
#[unstable(feature = "core")]
#[unstable(feature = "int_slice")]
#[deprecated(since = "1.2.0",
reason = "has not seen much usage and may want to live in the \
standard library now that most slice methods are \
on an inherent implementation block")]
pub trait IntSliceExt<U, S> {
/// Converts the slice to an immutable slice of unsigned integers with the same width.
fn as_unsigned<'a>(&'a self) -> &'a [U];
@ -1518,7 +1522,8 @@ pub trait IntSliceExt<U, S> {
macro_rules! impl_int_slice {
($u:ty, $s:ty, $t:ty) => {
#[unstable(feature = "core")]
#[unstable(feature = "int_slice")]
#[allow(deprecated)]
impl IntSliceExt<$u, $s> for [$t] {
#[inline]
fn as_unsigned(&self) -> &[$u] { unsafe { transmute(self) } }

View File

@ -13,6 +13,7 @@
//! For more details, see std::str
#![doc(primitive = "str")]
#![stable(feature = "rust1", since = "1.0.0")]
use self::OldSearcher::{TwoWay, TwoWayLong};
use self::pattern::Pattern;
@ -191,7 +192,7 @@ fn unwrap_or_0(opt: Option<&u8>) -> u8 {
/// Reads the next code point out of a byte iterator (assuming a
/// UTF-8-like encoding).
#[unstable(feature = "core")]
#[unstable(feature = "str_internals")]
#[inline]
pub fn next_code_point(bytes: &mut slice::Iter<u8>) -> Option<u32> {
// Decode UTF-8
@ -226,9 +227,8 @@ pub fn next_code_point(bytes: &mut slice::Iter<u8>) -> Option<u32> {
/// Reads the last code point out of a byte iterator (assuming a
/// UTF-8-like encoding).
#[unstable(feature = "core")]
#[inline]
pub fn next_code_point_reverse(bytes: &mut slice::Iter<u8>) -> Option<u32> {
fn next_code_point_reverse(bytes: &mut slice::Iter<u8>) -> Option<u32> {
// Decode UTF-8
let w = match bytes.next_back() {
None => return None,
@ -738,7 +738,7 @@ generate_pattern_iterators! {
#[doc="Created with the method `.rmatch_indices()`."]
struct RMatchIndices;
stability:
#[unstable(feature = "core",
#[unstable(feature = "str_match_indices",
reason = "type may be removed or have its iterator impl changed")]
internal:
MatchIndicesInternal yielding ((usize, usize));
@ -779,7 +779,7 @@ generate_pattern_iterators! {
#[doc="Created with the method `.rmatches()`."]
struct RMatches;
stability:
#[unstable(feature = "core", reason = "type got recently added")]
#[stable(feature = "str_matches", since = "1.2.0")]
internal:
MatchesInternal yielding (&'a str);
delegate double ended;
@ -1470,6 +1470,8 @@ mod traits {
/// Methods for string slices
#[allow(missing_docs)]
#[doc(hidden)]
#[unstable(feature = "core_str_ext",
reason = "stable interface provided by `impl str` in later crates")]
pub trait StrExt {
// NB there are no docs here are they're all located on the StrExt trait in
// libcollections, not here.
@ -1870,8 +1872,7 @@ impl AsRef<[u8]> for str {
/// Pluck a code point out of a UTF-8-like byte slice and return the
/// index of the next code point.
#[inline]
#[unstable(feature = "core")]
pub fn char_range_at_raw(bytes: &[u8], i: usize) -> (u32, usize) {
fn char_range_at_raw(bytes: &[u8], i: usize) -> (u32, usize) {
if bytes[i] < 128 {
return (bytes[i] as u32, i + 1);
}

View File

@ -13,6 +13,9 @@
//! For more details, see the traits `Pattern`, `Searcher`,
//! `ReverseSearcher` and `DoubleEndedSearcher`.
#![unstable(feature = "pattern",
reason = "API not fully fleshed out and ready to be stabilized")]
use prelude::*;
// Pattern

View File

@ -1,13 +0,0 @@
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Types dealing with unsafe actions.
use marker;

View File

@ -8,27 +8,45 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)
#![cfg_attr(stage0, feature(custom_attribute))]
#![feature(as_unsafe_cell)]
#![feature(borrow_state)]
#![feature(box_syntax)]
#![feature(unboxed_closures)]
#![feature(core)]
#![feature(const_fn)]
#![feature(test)]
#![feature(rand)]
#![feature(unicode)]
#![feature(std_misc)]
#![feature(libc)]
#![feature(hash)]
#![feature(unique)]
#![feature(step_by)]
#![feature(slice_patterns)]
#![feature(float_from_str_radix)]
#![feature(cell_extras)]
#![feature(cmp_partial)]
#![feature(const_fn)]
#![feature(core)]
#![feature(core_float)]
#![feature(float_extras)]
#![feature(float_from_str_radix)]
#![feature(flt2dec)]
#![feature(fmt_radix)]
#![feature(hash_default)]
#![feature(hasher_write)]
#![feature(iter_arith)]
#![feature(iter_arith)]
#![feature(iter_cmp)]
#![feature(iter_empty)]
#![feature(iter_idx)]
#![feature(iter_iterate)]
#![feature(iter_min_max)]
#![feature(iter_once)]
#![feature(iter_order)]
#![feature(iter_unfold)]
#![feature(libc)]
#![feature(nonzero)]
#![feature(num_bits_bytes)]
#![feature(ptr_as_ref)]
#![feature(rand)]
#![feature(range_inclusive)]
#![feature(raw)]
#![feature(result_expect)]
#![feature(slice_bytes)]
#![feature(slice_patterns)]
#![feature(step_by)]
#![feature(test)]
#![feature(unboxed_closures)]
#![feature(unicode)]
#![feature(unique)]
extern crate core;
extern crate test;

View File

@ -9,7 +9,6 @@
// except according to those terms.
use core::option::*;
use core::marker;
use core::mem;
use core::clone::Clone;
@ -81,7 +80,8 @@ fn test_option_dance() {
#[test] #[should_panic]
fn test_option_too_much_dance() {
let mut y = Some(marker::NoCopy);
struct A;
let mut y = Some(A);
let _y2 = y.take().unwrap();
let _y3 = y.take().unwrap();
}

View File

@ -28,7 +28,7 @@
#![feature(libc)]
#![feature(staged_api)]
#![feature(unique)]
#![cfg_attr(test, feature(rustc_private, rand, collections))]
#![cfg_attr(test, feature(rustc_private, rand, vec_push_all))]
#[cfg(test)] #[macro_use] extern crate log;

View File

@ -281,8 +281,9 @@
#![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_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(collections)]
#![feature(into_cow)]
#![feature(str_escape)]
use self::LabelText::*;

View File

@ -169,14 +169,14 @@
html_playground_url = "http://play.rust-lang.org/")]
#![deny(missing_docs)]
#![feature(alloc)]
#![feature(staged_api)]
#![feature(box_raw)]
#![feature(box_syntax)]
#![feature(core)]
#![feature(const_fn)]
#![feature(std_misc)]
#![feature(iter_cmp)]
#![feature(rt)]
#![feature(staged_api)]
#![feature(static_mutex)]
use std::boxed;
use std::cell::RefCell;
use std::fmt;
use std::io::{self, Stderr};
@ -435,12 +435,12 @@ fn init() {
assert!(FILTER.is_null());
match filter {
Some(f) => FILTER = boxed::into_raw(box f),
Some(f) => FILTER = Box::into_raw(box f),
None => {}
}
assert!(DIRECTIVES.is_null());
DIRECTIVES = boxed::into_raw(box directives);
DIRECTIVES = Box::into_raw(box directives);
// Schedule the cleanup for the globals for when the runtime exits.
let _ = rt::at_exit(move || {

View File

@ -29,11 +29,15 @@
#![unstable(feature = "rand",
reason = "use `rand` from crates.io")]
#![feature(core)]
#![feature(core_float)]
#![feature(core_prelude)]
#![feature(core_slice_ext)]
#![feature(no_std)]
#![feature(num_bits_bytes)]
#![feature(staged_api)]
#![feature(step_by)]
#![cfg_attr(test, feature(test, rand, rustc_private))]
#![cfg_attr(test, feature(test, rand, rustc_private, iter_order))]
#![allow(deprecated)]

View File

@ -123,9 +123,9 @@
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(core)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(slice_bytes)]
#![cfg_attr(test, feature(test))]

View File

@ -25,26 +25,41 @@
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(append)]
#![feature(associated_consts)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(clone_from_slice)]
#![feature(collections)]
#![feature(const_fn)]
#![feature(core)]
#![feature(duration)]
#![feature(duration_span)]
#![feature(dynamic_lib)]
#![feature(enumset)]
#![feature(fs_canonicalize)]
#![feature(hash)]
#![feature(hash_default)]
#![feature(hashmap_hasher)]
#![feature(into_cow)]
#![feature(iter_cmp)]
#![feature(iter_arith)]
#![feature(libc)]
#![feature(map_in_place)]
#![feature(num_bits_bytes)]
#![feature(path_ext)]
#![feature(quote)]
#![feature(range_inclusive)]
#![feature(ref_slice)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(slice_bytes)]
#![feature(slice_extras)]
#![feature(slice_patterns)]
#![feature(slice_position_elem)]
#![feature(staged_api)]
#![feature(std_misc)]
#![feature(str_char)]
#![feature(str_match_indices)]
#![feature(vec_push_all)]
#![feature(wrapping)]
#![cfg_attr(test, feature(test))]
#![allow(trivial_casts)]

View File

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

View File

@ -19,7 +19,7 @@
#![feature(no_std)]
#![no_std]
#![unstable(feature = "rustc_private")]
#![cfg_attr(test, feature(hash))]
#![cfg_attr(test, feature(hash_default))]
//! A typesafe bitmask flag generator.

View File

@ -26,14 +26,13 @@
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(box_syntax)]
#![feature(collections)]
#![feature(libc)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(exit_status)]
#![feature(set_stdio)]
#![feature(staged_api)]
#![feature(vec_push_all)]
extern crate arena;
extern crate flate;
@ -73,6 +72,7 @@ use std::env;
use std::io::{self, Read, Write};
use std::iter::repeat;
use std::path::PathBuf;
use std::process;
use std::str;
use std::sync::{Arc, Mutex};
use std::thread;
@ -861,5 +861,5 @@ pub fn diagnostics_registry() -> diagnostics::registry::Registry {
pub fn main() {
let result = run(env::args().collect());
std::env::set_exit_status(result as i32);
process::exit(result as i32);
}

View File

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

View File

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

View File

@ -19,11 +19,11 @@
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(alloc)]
#![feature(associated_consts)]
#![feature(collections)]
#![feature(rc_weak)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(slice_extras)]
#![feature(staged_api)]
#[macro_use] extern crate log;

View File

@ -25,7 +25,6 @@ use syntax::diagnostic::{Emitter, Handler, Level};
use std::ffi::{CStr, CString};
use std::fs;
use std::iter::Unfold;
use std::mem;
use std::path::Path;
use std::process::{Command, Stdio};
@ -913,11 +912,10 @@ fn run_work_singlethreaded(sess: &Session,
reachable: &[String],
work_items: Vec<WorkItem>) {
let cgcx = CodegenContext::new_with_session(sess, reachable);
let mut work_items = work_items;
// Since we're running single-threaded, we can pass the session to
// the proc, allowing `optimize_and_codegen` to perform LTO.
for work in Unfold::new((), |_| work_items.pop()) {
for work in work_items.into_iter().rev() {
execute_work_item(&cgcx, work);
}
}

View File

@ -25,21 +25,24 @@
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(alloc)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]
#![feature(const_fn)]
#![feature(iter_cmp)]
#![feature(iter_arith)]
#![feature(libc)]
#![feature(path_ext)]
#![feature(path_ext)]
#![feature(path_relative_from)]
#![feature(path_relative_from)]
#![feature(quote)]
#![feature(rc_weak)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(unicode)]
#![feature(path_ext)]
#![feature(path_relative_from)]
#![feature(std_misc)]
#![feature(unicode)]
#![feature(vec_push_all)]
#![allow(trivial_casts)]

View File

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

View File

@ -310,7 +310,9 @@ impl char {
#[unstable(feature = "unicode",
reason = "pending decision about Iterator/Writer/Reader")]
#[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
/// then returns the number of `u16`s written.
@ -345,7 +347,9 @@ impl char {
#[unstable(feature = "unicode",
reason = "pending decision about Iterator/Writer/Reader")]
#[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
/// alphabetic code point.
@ -541,5 +545,7 @@ impl char {
#[unstable(feature = "unicode",
reason = "needs expert opinion. is_cjk flag stands out as ugly")]
#[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

@ -24,18 +24,24 @@
#![cfg_attr(stage0, feature(custom_attribute))]
#![crate_name = "rustc_unicode"]
#![unstable(feature = "unicode")]
#![feature(lang_items)]
#![feature(staged_api)]
#![staged_api]
#![crate_type = "rlib"]
#![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_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(no_std)]
html_playground_url = "http://play.rust-lang.org/",
test(no_crate_inject))]
#![no_std]
#![feature(core)]
#![doc(test(no_crate_inject))]
#![feature(core_char_ext)]
#![feature(core_prelude)]
#![feature(core_slice_ext)]
#![feature(core_str_ext)]
#![feature(iter_arith)]
#![feature(lang_items)]
#![feature(no_std)]
#![feature(staged_api)]
extern crate core;

View File

@ -22,18 +22,20 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(collections)]
#![feature(exit_status)]
#![feature(set_stdio)]
#![feature(dynamic_lib)]
#![feature(libc)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(std_misc)]
#![feature(test)]
#![feature(unicode)]
#![feature(owned_ascii_ext)]
#![feature(path_ext)]
#![feature(path_relative_from)]
#![feature(rustc_private)]
#![feature(set_stdio)]
#![feature(slice_extras)]
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(subslice_offset)]
#![feature(test)]
#![feature(unicode)]
#![feature(vec_push_all)]
extern crate arena;
extern crate getopts;
@ -58,6 +60,7 @@ use std::env;
use std::fs::File;
use std::io::{self, Read, Write};
use std::path::PathBuf;
use std::process;
use std::rc::Rc;
use std::sync::mpsc::channel;
@ -131,7 +134,7 @@ pub fn main() {
let s = env::args().collect::<Vec<_>>();
main_args(&s)
}).unwrap().join().unwrap();
env::set_exit_status(res as i32);
process::exit(res as i32);
}
pub fn opts() -> Vec<getopts::OptGroup> {

View File

@ -29,12 +29,14 @@ Core encoding and decoding interfaces.
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]
#![feature(enumset)]
#![feature(hashmap_hasher)]
#![feature(num_bits_bytes)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(std_misc)]
#![feature(unicode)]
#![feature(str_char)]
#![feature(unicode)]
#![feature(vecmap)]
#![cfg_attr(test, feature(test))]
// test harness access

View File

@ -18,7 +18,7 @@ use ops::Range;
use mem;
/// Extension methods for ASCII-subset only operations on owned strings
#[unstable(feature = "std_misc",
#[unstable(feature = "owned_ascii_ext",
reason = "would prefer to do this in a more general way")]
pub trait OwnedAsciiExt {
/// Converts the string to ASCII upper case:
@ -189,8 +189,6 @@ impl AsciiExt for str {
}
}
#[unstable(feature = "std_misc",
reason = "would prefer to do this in a more general way")]
impl OwnedAsciiExt for String {
#[inline]
fn into_ascii_uppercase(self) -> String {
@ -244,8 +242,6 @@ impl AsciiExt for [u8] {
}
}
#[unstable(feature = "std_misc",
reason = "would prefer to do this in a more general way")]
impl OwnedAsciiExt for Vec<u8> {
#[inline]
fn into_ascii_uppercase(mut self) -> Vec<u8> {

View File

@ -43,8 +43,7 @@ use super::table::BucketState::{
use super::state::HashState;
const INITIAL_LOG2_CAP: usize = 5;
#[unstable(feature = "std_misc")]
pub const INITIAL_CAPACITY: usize = 1 << INITIAL_LOG2_CAP; // 2^5
const INITIAL_CAPACITY: usize = 1 << INITIAL_LOG2_CAP; // 2^5
/// The default behavior of HashMap implements a load factor of 90.9%.
/// This behavior is characterized by the following condition:
@ -544,7 +543,7 @@ impl<K, V, S> HashMap<K, V, S>
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(hashmap_hasher)]
/// use std::collections::HashMap;
/// use std::collections::hash_map::RandomState;
///
@ -553,7 +552,7 @@ impl<K, V, S> HashMap<K, V, S>
/// map.insert(1, 2);
/// ```
#[inline]
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
#[unstable(feature = "hashmap_hasher", reason = "hasher stuff is unclear")]
pub fn with_hash_state(hash_state: S) -> HashMap<K, V, S> {
HashMap {
hash_state: hash_state,
@ -573,7 +572,7 @@ impl<K, V, S> HashMap<K, V, S>
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(hashmap_hasher)]
/// use std::collections::HashMap;
/// use std::collections::hash_map::RandomState;
///
@ -582,7 +581,7 @@ impl<K, V, S> HashMap<K, V, S>
/// map.insert(1, 2);
/// ```
#[inline]
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
#[unstable(feature = "hashmap_hasher", reason = "hasher stuff is unclear")]
pub fn with_capacity_and_hash_state(capacity: usize, hash_state: S)
-> HashMap<K, V, S> {
let resize_policy = DefaultResizePolicy::new();
@ -980,7 +979,7 @@ impl<K, V, S> HashMap<K, V, S>
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(drain)]
/// use std::collections::HashMap;
///
/// let mut a = HashMap::new();
@ -995,7 +994,7 @@ impl<K, V, S> HashMap<K, V, S>
/// assert!(a.is_empty());
/// ```
#[inline]
#[unstable(feature = "std_misc",
#[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn drain(&mut self) -> Drain<K, V> {
fn last_two<A, B, C>((_, b, c): (A, B, C)) -> (B, C) { (b, c) }
@ -1308,7 +1307,7 @@ impl<'a, K, V> Clone for Values<'a, K, V> {
}
/// HashMap drain iterator.
#[unstable(feature = "std_misc",
#[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle")]
pub struct Drain<'a, K: 'a, V: 'a> {
inner: iter::Map<table::Drain<'a, K, V>, fn((SafeHash, K, V)) -> (K, V)>
@ -1480,7 +1479,7 @@ impl<'a, K, V> ExactSizeIterator for Drain<'a, K, V> {
}
impl<'a, K, V> Entry<'a, K, V> {
#[unstable(feature = "std_misc",
#[unstable(feature = "entry",
reason = "will soon be replaced by or_insert")]
#[deprecated(since = "1.0",
reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")]
@ -1596,14 +1595,14 @@ impl<K, V, S> Extend<(K, V)> for HashMap<K, V, S>
/// `Hasher`, but the hashers created by two different `RandomState`
/// instances are unlikely to produce the same result for the same values.
#[derive(Clone)]
#[unstable(feature = "std_misc",
#[unstable(feature = "hashmap_hasher",
reason = "hashing an hash maps may be altered")]
pub struct RandomState {
k0: u64,
k1: u64,
}
#[unstable(feature = "std_misc",
#[unstable(feature = "hashmap_hasher",
reason = "hashing an hash maps may be altered")]
impl RandomState {
/// Constructs a new `RandomState` that is initialized with random keys.
@ -1615,7 +1614,7 @@ impl RandomState {
}
}
#[unstable(feature = "std_misc",
#[unstable(feature = "hashmap_hasher",
reason = "hashing an hash maps may be altered")]
impl HashState for RandomState {
type Hasher = SipHasher;

View File

@ -20,9 +20,11 @@ use iter::{Iterator, IntoIterator, ExactSizeIterator, FromIterator, Map, Chain,
use ops::{BitOr, BitAnd, BitXor, Sub};
use option::Option::{Some, None, self};
use super::map::{self, HashMap, Keys, INITIAL_CAPACITY, RandomState};
use super::map::{self, HashMap, Keys, RandomState};
use super::state::HashState;
const INITIAL_CAPACITY: usize = 32;
// Future Optimization (FIXME!)
// =============================
//
@ -152,7 +154,7 @@ impl<T, S> HashSet<T, S>
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(hashmap_hasher)]
/// use std::collections::HashSet;
/// use std::collections::hash_map::RandomState;
///
@ -161,7 +163,7 @@ impl<T, S> HashSet<T, S>
/// set.insert(2);
/// ```
#[inline]
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
#[unstable(feature = "hashmap_hasher", reason = "hasher stuff is unclear")]
pub fn with_hash_state(hash_state: S) -> HashSet<T, S> {
HashSet::with_capacity_and_hash_state(INITIAL_CAPACITY, hash_state)
}
@ -177,7 +179,7 @@ impl<T, S> HashSet<T, S>
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(hashmap_hasher)]
/// use std::collections::HashSet;
/// use std::collections::hash_map::RandomState;
///
@ -186,7 +188,7 @@ impl<T, S> HashSet<T, S>
/// set.insert(1);
/// ```
#[inline]
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
#[unstable(feature = "hashmap_hasher", reason = "hasher stuff is unclear")]
pub fn with_capacity_and_hash_state(capacity: usize, hash_state: S)
-> HashSet<T, S> {
HashSet {
@ -406,7 +408,7 @@ impl<T, S> HashSet<T, S>
/// Clears the set, returning all elements in an iterator.
#[inline]
#[unstable(feature = "std_misc",
#[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn drain(&mut self) -> Drain<T> {
fn first<A, B>((a, _): (A, B)) -> A { a }

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![unstable(feature = "hashmap_hasher", reason = "hasher stuff is unclear")]
use clone::Clone;
use default::Default;
use hash;
@ -25,7 +27,6 @@ use marker;
/// algorithm can implement the `Default` trait and create hash maps with the
/// `DefaultState` structure. This state is 0-sized and will simply delegate
/// to `Default` when asked to create a hasher.
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
pub trait HashState {
/// Type of the hasher that will be created.
type Hasher: hash::Hasher;
@ -38,7 +39,6 @@ pub trait HashState {
/// default trait.
///
/// This struct has is 0-sized and does not need construction.
#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")]
pub struct DefaultState<H>(marker::PhantomData<H>);
impl<H: Default + hash::Hasher> HashState for DefaultState<H> {

View File

@ -410,7 +410,7 @@ pub mod hash_set {
/// Experimental support for providing custom hash algorithms to a HashMap and
/// HashSet.
#[unstable(feature = "std_misc", reason = "module was recently added")]
#[unstable(feature = "hashmap_hasher", reason = "module was recently added")]
pub mod hash_state {
pub use super::hash::state::*;
}

View File

@ -12,7 +12,9 @@
//!
//! A simple wrapper over the platform's dynamic library facilities
#![unstable(feature = "std_misc")]
#![unstable(feature = "dynamic_lib",
reason = "API has not been scrutinized and is highly likely to \
either disappear or change")]
#![allow(missing_docs)]
use prelude::v1::*;

View File

@ -486,6 +486,7 @@ static EXIT_STATUS: AtomicIsize = AtomicIsize::new(0);
///
/// Note that this is not synchronized against modifications of other threads.
#[unstable(feature = "exit_status", reason = "managing the exit status may change")]
#[deprecated(since = "1.2.0", reason = "use process::exit instead")]
pub fn set_exit_status(code: i32) {
EXIT_STATUS.store(code as isize, Ordering::SeqCst)
}
@ -493,6 +494,7 @@ pub fn set_exit_status(code: i32) {
/// Fetches the process's current exit code. This defaults to 0 and can change
/// by calling `set_exit_status`.
#[unstable(feature = "exit_status", reason = "managing the exit status may change")]
#[deprecated(since = "1.2.0", reason = "use process::exit instead")]
pub fn get_exit_status() -> i32 {
EXIT_STATUS.load(Ordering::SeqCst) as i32
}

View File

@ -48,7 +48,7 @@
// reconsider what crate these items belong in.
use any::TypeId;
use boxed::{self, Box};
use boxed::Box;
use convert::From;
use fmt::{self, Debug, Display};
use marker::{Send, Sync, Reflect};
@ -77,7 +77,7 @@ pub trait Error: Debug + Display + Reflect {
/// Get the `TypeId` of `self`
#[doc(hidden)]
#[unstable(feature = "core",
#[unstable(feature = "error_type_id",
reason = "unclear whether to commit to this public implementation detail")]
fn type_id(&self) -> TypeId where Self: 'static {
TypeId::of::<Self>()
@ -140,7 +140,7 @@ impl Error for str::Utf8Error {
#[stable(feature = "rust1", since = "1.0.0")]
impl Error for num::ParseIntError {
fn description(&self) -> &str {
self.description()
self.__description()
}
}
@ -249,7 +249,7 @@ impl Error {
if self.is::<T>() {
unsafe {
// Get the raw representation of the trait object
let raw = boxed::into_raw(self);
let raw = Box::into_raw(self);
let to: TraitObject =
transmute::<*mut Error, TraitObject>(raw);

View File

@ -8,10 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![unstable(feature = "std_misc")]
use borrow::{Cow, ToOwned};
use boxed::{self, Box};
use boxed::Box;
use clone::Clone;
use convert::{Into, From};
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
@ -208,6 +206,9 @@ impl CString {
/// `into_ptr`. The length of the string will be recalculated
/// using the pointer.
#[unstable(feature = "cstr_memory", reason = "recently added")]
// NB: may want to be called from_raw, needs to consider CStr::from_ptr,
// Box::from_raw (or whatever it's currently called), and
// slice::from_raw_parts
pub unsafe fn from_ptr(ptr: *const libc::c_char) -> CString {
let len = libc::strlen(ptr) + 1; // Including the NUL byte
let slice = slice::from_raw_parts(ptr, len as usize);
@ -223,11 +224,12 @@ impl CString {
///
/// Failure to call `from_ptr` will lead to a memory leak.
#[unstable(feature = "cstr_memory", reason = "recently added")]
// NB: may want to be called into_raw, see comments on from_ptr
pub fn into_ptr(self) -> *const libc::c_char {
// It is important that the bytes be sized to fit - we need
// the capacity to be determinable from the string length, and
// shrinking to fit is the only way to be sure.
boxed::into_raw(self.inner) as *const libc::c_char
Box::into_raw(self.inner) as *const libc::c_char
}
/// Returns the contents of this `CString` as a slice of bytes.

View File

@ -454,6 +454,8 @@ impl<W: Read + Write> Read for InternalBufWriter<W> {
#[unstable(feature = "buf_stream",
reason = "unsure about semantics of buffering two directions, \
leading to issues like #17136")]
#[deprecated(since = "1.2.0",
reason = "use the crates.io `bufstream` crate instead")]
pub struct BufStream<S: Write> {
inner: BufReader<InternalBufWriter<S>>
}
@ -461,6 +463,9 @@ pub struct BufStream<S: Write> {
#[unstable(feature = "buf_stream",
reason = "unsure about semantics of buffering two directions, \
leading to issues like #17136")]
#[deprecated(since = "1.2.0",
reason = "use the crates.io `bufstream` crate instead")]
#[allow(deprecated)]
impl<S: Read + Write> BufStream<S> {
/// Creates a new buffered stream with explicitly listed capacities for the
/// reader/writer buffer.
@ -512,6 +517,7 @@ impl<S: Read + Write> BufStream<S> {
#[unstable(feature = "buf_stream",
reason = "unsure about semantics of buffering two directions, \
leading to issues like #17136")]
#[allow(deprecated)]
impl<S: Read + Write> BufRead for BufStream<S> {
fn fill_buf(&mut self) -> io::Result<&[u8]> { self.inner.fill_buf() }
fn consume(&mut self, amt: usize) { self.inner.consume(amt) }
@ -520,6 +526,7 @@ impl<S: Read + Write> BufRead for BufStream<S> {
#[unstable(feature = "buf_stream",
reason = "unsure about semantics of buffering two directions, \
leading to issues like #17136")]
#[allow(deprecated)]
impl<S: Read + Write> Read for BufStream<S> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.inner.read(buf)
@ -529,6 +536,7 @@ impl<S: Read + Write> Read for BufStream<S> {
#[unstable(feature = "buf_stream",
reason = "unsure about semantics of buffering two directions, \
leading to issues like #17136")]
#[allow(deprecated)]
impl<S: Read + Write> Write for BufStream<S> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.inner.get_mut().write(buf)
@ -541,6 +549,7 @@ impl<S: Read + Write> Write for BufStream<S> {
#[unstable(feature = "buf_stream",
reason = "unsure about semantics of buffering two directions, \
leading to issues like #17136")]
#[allow(deprecated)]
impl<S: Write> fmt::Debug for BufStream<S> where S: fmt::Debug {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let reader = &self.inner;

View File

@ -123,7 +123,7 @@ pub enum ErrorKind {
Other,
/// Any I/O error not part of this list.
#[unstable(feature = "std_misc",
#[unstable(feature = "io_error_internals",
reason = "better expressed through extensible enums that this \
enum cannot be exhaustively matched against")]
#[doc(hidden)]

View File

@ -10,7 +10,6 @@
use prelude::v1::*;
use boxed;
use cell::Cell;
use rt;
use sync::{StaticMutex, Arc};
@ -60,7 +59,7 @@ impl<T: Send + Sync + 'static> Lazy<T> {
});
let ret = (self.init)();
if registered.is_ok() {
self.ptr.set(boxed::into_raw(Box::new(ret.clone())));
self.ptr.set(Box::into_raw(Box::new(ret.clone())));
}
return ret
}

View File

@ -99,38 +99,62 @@
#![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_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![doc(test(no_crate_inject, attr(deny(warnings))))]
#![doc(test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
html_playground_url = "http://play.rust-lang.org/",
test(no_crate_inject, attr(deny(warnings))),
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
#![feature(alloc)]
#![feature(allow_internal_unstable)]
#![feature(associated_consts)]
#![feature(borrow_state)]
#![feature(box_raw)]
#![feature(box_syntax)]
#![feature(char_internals)]
#![feature(clone_from_slice)]
#![feature(collections)]
#![feature(core)]
#![feature(collections_bound)]
#![feature(const_fn)]
#![feature(core)]
#![feature(core_float)]
#![feature(core_intrinsics)]
#![feature(core_prelude)]
#![feature(core_simd)]
#![feature(fnbox)]
#![feature(heap_api)]
#![feature(int_error_internals)]
#![feature(into_cow)]
#![feature(iter_order)]
#![feature(lang_items)]
#![feature(libc)]
#![feature(linkage, thread_local, asm)]
#![feature(macro_reexport)]
#![feature(slice_concat_ext)]
#![feature(slice_position_elem)]
#![feature(no_std)]
#![feature(oom)]
#![feature(optin_builtin_traits)]
#![feature(rand)]
#![feature(raw)]
#![feature(reflect_marker)]
#![feature(slice_bytes)]
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(std_misc)]
#![feature(str_char)]
#![feature(str_internals)]
#![feature(unboxed_closures)]
#![feature(unicode)]
#![feature(unique)]
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(vec_push_all)]
#![feature(wrapping)]
#![feature(zero_one)]
#![cfg_attr(test, feature(float_from_str_radix))]
#![cfg_attr(test, feature(test, rustc_private, std_misc))]
#![cfg_attr(all(unix, not(target_os = "macos"), not(target_os = "ios")),
feature(num_bits_bytes))]
#![cfg_attr(windows, feature(str_utf16))]
#![cfg_attr(test, feature(float_from_str_radix, range_inclusive, float_extras))]
#![cfg_attr(test, feature(test, rustc_private, float_consts))]
// Don't link to std. We are std.
#![feature(no_std)]
#![no_std]
#![allow(trivial_casts)]

View File

@ -14,8 +14,6 @@
//! library. Each macro is available for use when linking against the standard
//! library.
#![unstable(feature = "std_misc")]
/// The entry point for panic of Rust threads.
///
/// This macro is used to inject panic into a Rust thread, causing the thread to
@ -165,7 +163,7 @@ macro_rules! try {
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(mpsc_select)]
/// use std::thread;
/// use std::sync::mpsc;
///
@ -191,7 +189,7 @@ macro_rules! try {
///
/// For more information about select, see the `std::sync::mpsc::Select` structure.
#[macro_export]
#[unstable(feature = "std_misc")]
#[unstable(feature = "mpsc_select")]
macro_rules! select {
(
$($name:pat = $rx:ident.$meth:ident() => $code:expr),+

View File

@ -194,7 +194,7 @@ impl f32 {
/// The floating point encoding is documented in the [Reference][floating-point].
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(float_extras)]
/// use std::f32;
///
/// let num = 2.0f32;
@ -211,9 +211,11 @@ impl f32 {
/// assert!(abs_difference <= f32::EPSILON);
/// ```
/// [floating-point]: ../../../../../reference.html#machine-types
#[unstable(feature = "std_misc", reason = "signature is undecided")]
#[unstable(feature = "float_extras", reason = "signature is undecided")]
#[inline]
pub fn integer_decode(self) -> (u64, i16, i8) { num::Float::integer_decode(self) }
pub fn integer_decode(self) -> (u64, i16, i8) {
num::Float::integer_decode(self)
}
/// Returns the largest integer less than or equal to a number.
///
@ -555,7 +557,7 @@ impl f32 {
/// Converts radians to degrees.
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(float_extras)]
/// use std::f32::{self, consts};
///
/// let angle = consts::PI;
@ -564,14 +566,14 @@ impl f32 {
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
#[unstable(feature = "std_misc", reason = "desirability is unclear")]
#[unstable(feature = "float_extras", reason = "desirability is unclear")]
#[inline]
pub fn to_degrees(self) -> f32 { num::Float::to_degrees(self) }
/// Converts degrees to radians.
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(float_extras)]
/// use std::f32::{self, consts};
///
/// let angle = 180.0f32;
@ -580,21 +582,21 @@ impl f32 {
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
#[unstable(feature = "std_misc", reason = "desirability is unclear")]
#[unstable(feature = "float_extras", reason = "desirability is unclear")]
#[inline]
pub fn to_radians(self) -> f32 { num::Float::to_radians(self) }
/// Constructs a floating point number of `x*2^exp`.
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(float_extras)]
/// use std::f32;
/// // 3*2^2 - 12 == 0
/// let abs_difference = (f32::ldexp(3.0, 2) - 12.0).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
#[unstable(feature = "std_misc",
#[unstable(feature = "float_extras",
reason = "pending integer conventions")]
#[inline]
pub fn ldexp(x: f32, exp: isize) -> f32 {
@ -608,7 +610,7 @@ impl f32 {
/// * `0.5 <= abs(x) < 1.0`
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(float_extras)]
/// use std::f32;
///
/// let x = 4.0f32;
@ -621,7 +623,7 @@ impl f32 {
/// assert!(abs_difference_0 <= f32::EPSILON);
/// assert!(abs_difference_1 <= f32::EPSILON);
/// ```
#[unstable(feature = "std_misc",
#[unstable(feature = "float_extras",
reason = "pending integer conventions")]
#[inline]
pub fn frexp(self) -> (f32, isize) {
@ -636,7 +638,7 @@ impl f32 {
/// `other`.
///
/// ```
/// # #![feature(std_misc)]
/// # #![feature(float_extras)]
/// use std::f32;
///
/// let x = 1.0f32;
@ -645,7 +647,7 @@ impl f32 {
///
/// assert!(abs_diff <= f32::EPSILON);
/// ```
#[unstable(feature = "std_misc",
#[unstable(feature = "float_extras",
reason = "unsure about its place in the world")]
#[inline]
pub fn next_after(self, other: f32) -> f32 {

Some files were not shown because too many files have changed in this diff Show More