diff options
| author | bors <bors@rust-lang.org> | 2014-12-17 21:33:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-17 21:33:15 +0000 |
| commit | 22a9f250b5e2de64c13c0f056aec13eb086ef79d (patch) | |
| tree | d996edc2a0a259556be226b4f60437f961fb09b2 /src/liballoc | |
| parent | 66c297d847ce06a8982d4d322221b17a3cd04f90 (diff) | |
| parent | 5c98952409c9123b5f26b3c620029cd1914a07b6 (diff) | |
| download | rust-22a9f250b5e2de64c13c0f056aec13eb086ef79d.tar.gz rust-22a9f250b5e2de64c13c0f056aec13eb086ef79d.zip | |
auto merge of #19958 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/arc.rs | 9 | ||||
| -rw-r--r-- | src/liballoc/boxed.rs | 4 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 1f1909fd33c..ee4efa2d273 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -14,6 +14,7 @@ //! between tasks. use core::atomic; +use core::borrow::BorrowFrom; use core::clone::Clone; use core::fmt::{mod, Show}; use core::cmp::{Eq, Ord, PartialEq, PartialOrd, Ordering}; @@ -155,6 +156,12 @@ impl<T> Clone for Arc<T> { } } +impl<T> BorrowFrom<Arc<T>> for T { + fn borrow_from(owned: &Arc<T>) -> &T { + &**owned + } +} + #[experimental = "Deref is experimental."] impl<T> Deref<T> for Arc<T> { #[inline] @@ -316,7 +323,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()) } } diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index c6afeb063fb..879a8cc6951 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -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 [] } } diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 7af816f2e09..0257c640d3c 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -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()) } |
