rollup merge of #19902: alexcrichton/second-pass-mem
This commit stabilizes the `mem` and `default` modules of std.
This commit is contained in:
commit
3369b33a20
@ -316,7 +316,9 @@ impl<T: fmt::Show> fmt::Show for Arc<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T: Default + Sync + Send> Default for Arc<T> {
|
||||
#[stable]
|
||||
fn default() -> Arc<T> { Arc::new(Default::default()) }
|
||||
}
|
||||
|
||||
|
@ -45,11 +45,15 @@ pub static HEAP: () = ();
|
||||
#[unstable = "custom allocators will add an additional type parameter (with default)"]
|
||||
pub struct Box<T>(*mut T);
|
||||
|
||||
#[stable]
|
||||
impl<T: Default> Default for Box<T> {
|
||||
#[stable]
|
||||
fn default() -> Box<T> { box Default::default() }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T> Default for Box<[T]> {
|
||||
#[stable]
|
||||
fn default() -> Box<[T]> { box [] }
|
||||
}
|
||||
|
||||
|
@ -448,6 +448,7 @@ impl<T: Default> Default for Rc<T> {
|
||||
/// let x: Rc<int> = Default::default();
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable]
|
||||
fn default() -> Rc<T> {
|
||||
Rc::new(Default::default())
|
||||
}
|
||||
|
@ -172,8 +172,10 @@ pub struct BinaryHeap<T> {
|
||||
data: Vec<T>,
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T: Ord> Default for BinaryHeap<T> {
|
||||
#[inline]
|
||||
#[stable]
|
||||
fn default() -> BinaryHeap<T> { BinaryHeap::new() }
|
||||
}
|
||||
|
||||
|
@ -824,8 +824,10 @@ pub fn from_fn<F>(len: uint, mut f: F) -> Bitv where F: FnMut(uint) -> bool {
|
||||
bitv
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl Default for Bitv {
|
||||
#[inline]
|
||||
#[stable]
|
||||
fn default() -> Bitv { Bitv::new() }
|
||||
}
|
||||
|
||||
|
@ -832,7 +832,9 @@ impl<S: Writer, K: Hash<S>, V: Hash<S>> Hash<S> for BTreeMap<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<K: Ord, V> Default for BTreeMap<K, V> {
|
||||
#[stable]
|
||||
fn default() -> BTreeMap<K, V> {
|
||||
BTreeMap::new()
|
||||
}
|
||||
|
@ -439,7 +439,9 @@ impl<T: Ord> Extend<T> for BTreeSet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T: Ord> Default for BTreeSet<T> {
|
||||
#[stable]
|
||||
fn default() -> BTreeSet<T> {
|
||||
BTreeSet::new()
|
||||
}
|
||||
|
@ -192,8 +192,10 @@ impl<T> DList<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T> Default for DList<T> {
|
||||
#[inline]
|
||||
#[stable]
|
||||
fn default() -> DList<T> { DList::new() }
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,9 @@ impl<T> Drop for RingBuf<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T> Default for RingBuf<T> {
|
||||
#[stable]
|
||||
#[inline]
|
||||
fn default() -> RingBuf<T> { RingBuf::new() }
|
||||
}
|
||||
|
@ -826,6 +826,7 @@ impl StrAllocating for String {
|
||||
|
||||
#[stable]
|
||||
impl Default for String {
|
||||
#[stable]
|
||||
fn default() -> String {
|
||||
String::new()
|
||||
}
|
||||
|
@ -185,8 +185,10 @@ impl<K: Ord + Show, V: Show> Show for TreeMap<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<K: Ord, V> Default for TreeMap<K,V> {
|
||||
#[inline]
|
||||
#[stable]
|
||||
fn default() -> TreeMap<K, V> { TreeMap::new() }
|
||||
}
|
||||
|
||||
|
@ -134,8 +134,10 @@ impl<T: Ord + Show> Show for TreeSet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T: Ord> Default for TreeSet<T> {
|
||||
#[inline]
|
||||
#[stable]
|
||||
fn default() -> TreeSet<T> { TreeSet::new() }
|
||||
}
|
||||
|
||||
|
@ -150,8 +150,10 @@ impl<T: Show> Show for TrieMap<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T> Default for TrieMap<T> {
|
||||
#[inline]
|
||||
#[stable]
|
||||
fn default() -> TrieMap<T> { TrieMap::new() }
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,10 @@ impl Show for TrieSet {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl Default for TrieSet {
|
||||
#[inline]
|
||||
#[stable]
|
||||
fn default() -> TrieSet { TrieSet::new() }
|
||||
}
|
||||
|
||||
|
@ -1330,6 +1330,7 @@ impl<T> Drop for Vec<T> {
|
||||
|
||||
#[stable]
|
||||
impl<T> Default for Vec<T> {
|
||||
#[stable]
|
||||
fn default() -> Vec<T> {
|
||||
Vec::new()
|
||||
}
|
||||
|
@ -66,7 +66,9 @@ pub struct VecMap<V> {
|
||||
v: Vec<Option<V>>,
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<V> Default for VecMap<V> {
|
||||
#[stable]
|
||||
#[inline]
|
||||
fn default() -> VecMap<V> { VecMap::new() }
|
||||
}
|
||||
|
@ -215,8 +215,9 @@ impl<T:Copy> Clone for Cell<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable]
|
||||
#[stable]
|
||||
impl<T:Default + Copy> Default for Cell<T> {
|
||||
#[stable]
|
||||
fn default() -> Cell<T> {
|
||||
Cell::new(Default::default())
|
||||
}
|
||||
@ -347,8 +348,9 @@ impl<T: Clone> Clone for RefCell<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable]
|
||||
#[stable]
|
||||
impl<T:Default> Default for RefCell<T> {
|
||||
#[stable]
|
||||
fn default() -> RefCell<T> {
|
||||
RefCell::new(Default::default())
|
||||
}
|
||||
|
@ -97,6 +97,7 @@
|
||||
/// bar: f32,
|
||||
/// }
|
||||
/// ```
|
||||
#[stable]
|
||||
pub trait Default {
|
||||
/// Returns the "default value" for a type.
|
||||
///
|
||||
@ -130,13 +131,16 @@ pub trait Default {
|
||||
/// fn default() -> Kind { Kind::A }
|
||||
/// }
|
||||
/// ```
|
||||
#[stable]
|
||||
fn default() -> Self;
|
||||
}
|
||||
|
||||
macro_rules! default_impl(
|
||||
($t:ty, $v:expr) => {
|
||||
#[stable]
|
||||
impl Default for $t {
|
||||
#[inline]
|
||||
#[stable]
|
||||
fn default() -> $t { $v }
|
||||
}
|
||||
}
|
||||
|
@ -203,8 +203,10 @@ impl Clone for SipState {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl Default for SipState {
|
||||
#[inline]
|
||||
#[stable]
|
||||
fn default() -> SipState {
|
||||
SipState::new()
|
||||
}
|
||||
|
@ -217,6 +217,7 @@ extern "rust-intrinsic" {
|
||||
///
|
||||
/// `forget` is unsafe because the caller is responsible for
|
||||
/// ensuring the argument is deallocated already.
|
||||
#[stable]
|
||||
pub fn forget<T>(_: T) -> ();
|
||||
|
||||
/// Unsafely transforms a value of one type into a value of another type.
|
||||
@ -232,6 +233,7 @@ extern "rust-intrinsic" {
|
||||
/// let v: &[u8] = unsafe { mem::transmute("L") };
|
||||
/// assert!(v == [76u8]);
|
||||
/// ```
|
||||
#[stable]
|
||||
pub fn transmute<T,U>(e: T) -> U;
|
||||
|
||||
/// Gives the address for the return value of the enclosing function.
|
||||
|
@ -13,9 +13,13 @@
|
||||
//! This module contains functions for querying the size and alignment of
|
||||
//! types, initializing and manipulating memory.
|
||||
|
||||
#![stable]
|
||||
|
||||
use kinds::Sized;
|
||||
use intrinsics;
|
||||
use ptr;
|
||||
|
||||
#[stable]
|
||||
pub use intrinsics::transmute;
|
||||
|
||||
/// Moves a thing into the void.
|
||||
@ -223,7 +227,8 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
|
||||
#[inline]
|
||||
#[unstable = "this function may be removed in the future due to its \
|
||||
questionable utility"]
|
||||
pub unsafe fn copy_lifetime<'a, S, T:'a>(_ptr: &'a S, ptr: &T) -> &'a T {
|
||||
pub unsafe fn copy_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a S,
|
||||
ptr: &T) -> &'a T {
|
||||
transmute(ptr)
|
||||
}
|
||||
|
||||
@ -231,7 +236,8 @@ pub unsafe fn copy_lifetime<'a, S, T:'a>(_ptr: &'a S, ptr: &T) -> &'a T {
|
||||
#[inline]
|
||||
#[unstable = "this function may be removed in the future due to its \
|
||||
questionable utility"]
|
||||
pub unsafe fn copy_mut_lifetime<'a, S, T:'a>(_ptr: &'a mut S,
|
||||
ptr: &mut T) -> &'a mut T {
|
||||
pub unsafe fn copy_mut_lifetime<'a, Sized? S, Sized? T: 'a>(_ptr: &'a mut S,
|
||||
ptr: &mut T)
|
||||
-> &'a mut T {
|
||||
transmute(ptr)
|
||||
}
|
||||
|
@ -763,6 +763,7 @@ impl<T> AsSlice<T> for Option<T> {
|
||||
|
||||
#[stable]
|
||||
impl<T> Default for Option<T> {
|
||||
#[stable]
|
||||
#[inline]
|
||||
#[stable]
|
||||
fn default() -> Option<T> { None }
|
||||
|
@ -645,8 +645,9 @@ impl<'a, T, Sized? U: AsSlice<T>> AsSlice<T> for &'a mut U {
|
||||
fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) }
|
||||
}
|
||||
|
||||
#[unstable = "waiting for DST"]
|
||||
#[stable]
|
||||
impl<'a, T> Default for &'a [T] {
|
||||
#[stable]
|
||||
fn default() -> &'a [T] { &[] }
|
||||
}
|
||||
|
||||
|
@ -2349,7 +2349,9 @@ impl StrPrelude for str {
|
||||
fn len(&self) -> uint { self.repr().len }
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<'a> Default for &'a str {
|
||||
#[stable]
|
||||
fn default() -> &'a str { "" }
|
||||
}
|
||||
|
||||
|
@ -182,6 +182,7 @@ macro_rules! tuple_impls {
|
||||
|
||||
#[stable]
|
||||
impl<$($T:Default),+> Default for ($($T,)+) {
|
||||
#[stable]
|
||||
#[inline]
|
||||
fn default() -> ($($T,)+) {
|
||||
($({ let x: $T = Default::default(); x},)+)
|
||||
|
@ -142,7 +142,9 @@ impl<R: Rng + Default> Reseeder<R> for ReseedWithDefault {
|
||||
*rng = Default::default();
|
||||
}
|
||||
}
|
||||
#[stable]
|
||||
impl Default for ReseedWithDefault {
|
||||
#[stable]
|
||||
fn default() -> ReseedWithDefault { ReseedWithDefault }
|
||||
}
|
||||
|
||||
|
@ -1288,7 +1288,9 @@ impl<K: Eq + Hash<S> + Show, V: Show, S, H: Hasher<S>> Show for HashMap<K, V, H>
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H> {
|
||||
#[stable]
|
||||
fn default() -> HashMap<K, V, H> {
|
||||
HashMap::with_hasher(Default::default())
|
||||
}
|
||||
|
@ -608,7 +608,9 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Extend<T> for HashSet<T, H> {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Default for HashSet<T, H> {
|
||||
#[stable]
|
||||
fn default() -> HashSet<T, H> {
|
||||
HashSet::with_hasher(Default::default())
|
||||
}
|
||||
|
@ -95,7 +95,9 @@ impl Hasher<sip::SipState> for RandomSipHasher {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable]
|
||||
impl Default for RandomSipHasher {
|
||||
#[stable]
|
||||
#[inline]
|
||||
fn default() -> RandomSipHasher {
|
||||
RandomSipHasher::new()
|
||||
|
@ -1911,7 +1911,9 @@ bitflags! {
|
||||
}
|
||||
|
||||
|
||||
#[stable]
|
||||
impl Default for FilePermission {
|
||||
#[stable]
|
||||
#[inline]
|
||||
fn default() -> FilePermission { FilePermission::empty() }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user