]> git.lizzy.rs Git - rust.git/commitdiff
Stabilization for `owned` (now `boxed`) and `cell`
authorAaron Turon <aturon@mozilla.com>
Thu, 10 Jul 2014 21:19:17 +0000 (14:19 -0700)
committerAaron Turon <aturon@mozilla.com>
Sun, 13 Jul 2014 19:52:51 +0000 (12:52 -0700)
This PR is the outcome of the library stabilization meeting for the
`liballoc::owned` and `libcore::cell` modules.

Aside from the stability attributes, there are a few breaking changes:

* The `owned` modules is now named `boxed`, to better represent its
  contents. (`box` was unavailable, since it's a keyword.) This will
  help avoid the misconception that `Box` plays a special role wrt
  ownership.

* The `AnyOwnExt` extension trait is renamed to `BoxAny`, and its `move`
  method is renamed to `downcast`, in both cases to improve clarity.

* The recently-added `AnySendOwnExt` extension trait is removed; it was
  not being used and is unnecessary.

[breaking-change]

50 files changed:
src/liballoc/boxed.rs [new file with mode: 0644]
src/liballoc/lib.rs
src/liballoc/owned.rs [deleted file]
src/libcollections/btree.rs
src/libcollections/dlist.rs
src/libcollections/hash/mod.rs
src/libcollections/treemap.rs
src/libcollections/trie.rs
src/libcore/cell.rs
src/librustrt/args.rs
src/librustrt/at_exit_imp.rs
src/librustrt/lib.rs
src/librustrt/local.rs
src/librustrt/local_data.rs
src/librustrt/local_ptr.rs
src/librustrt/rtio.rs
src/librustrt/stack.rs
src/librustrt/task.rs
src/librustrt/thread.rs
src/librustrt/unwind.rs
src/libstd/collections/lru_cache.rs
src/libstd/failure.rs
src/libstd/io/fs.rs
src/libstd/io/mod.rs
src/libstd/io/net/tcp.rs
src/libstd/io/net/udp.rs
src/libstd/io/net/unix.rs
src/libstd/io/pipe.rs
src/libstd/io/process.rs
src/libstd/io/signal.rs
src/libstd/io/stdio.rs
src/libstd/io/timer.rs
src/libstd/io/util.rs
src/libstd/lib.rs
src/libstd/prelude.rs
src/libstd/task.rs
src/libsync/atomics.rs
src/libsync/comm/mod.rs
src/libsync/comm/oneshot.rs
src/libsync/comm/select.rs
src/libsync/comm/shared.rs
src/libsync/comm/stream.rs
src/libsync/comm/sync.rs
src/libsync/deque.rs
src/libsync/mpsc_queue.rs
src/libsync/mutex.rs
src/libsync/spsc_queue.rs
src/test/compile-fail/new-box-syntax-bad.rs
src/test/run-pass/new-box-syntax.rs
src/test/run-pass/unit-like-struct-drop-run.rs

diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
new file mode 100644 (file)
index 0000000..56506d7
--- /dev/null
@@ -0,0 +1,180 @@
+// Copyright 2012 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.
+
+//! A unique pointer type
+
+use core::any::{Any, AnyRefExt};
+use core::clone::Clone;
+use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
+use core::default::Default;
+use core::fmt;
+use core::intrinsics;
+use core::mem;
+use core::option::Option;
+use core::raw::TraitObject;
+use core::result::{Ok, Err, Result};
+
+/// A value that represents the global exchange heap. This is the default
+/// place that the `box` keyword allocates into when no place is supplied.
+///
+/// The following two examples are equivalent:
+///
+///     use std::boxed::HEAP;
+///
+///     # struct Bar;
+///     # impl Bar { fn new(_a: int) { } }
+///     let foo = box(HEAP) Bar::new(2);
+///     let foo = box Bar::new(2);
+#[lang = "exchange_heap"]
+#[experimental = "may be renamed; uncertain about custom allocator design"]
+pub static HEAP: () = ();
+
+/// A type that represents a uniquely-owned value.
+#[lang = "owned_box"]
+#[unstable = "custom allocators will add an additional type parameter (with default)"]
+pub struct Box<T>(*mut T);
+
+impl<T: Default> Default for Box<T> {
+    fn default() -> Box<T> { box Default::default() }
+}
+
+#[unstable]
+impl<T: Clone> Clone for Box<T> {
+    /// Return a copy of the owned box.
+    #[inline]
+    fn clone(&self) -> Box<T> { box {(**self).clone()} }
+
+    /// Perform copy-assignment from `source` by reusing the existing allocation.
+    #[inline]
+    fn clone_from(&mut self, source: &Box<T>) {
+        (**self).clone_from(&(**source));
+    }
+}
+
+impl<T:PartialEq> PartialEq for Box<T> {
+    #[inline]
+    fn eq(&self, other: &Box<T>) -> bool { *(*self) == *(*other) }
+    #[inline]
+    fn ne(&self, other: &Box<T>) -> bool { *(*self) != *(*other) }
+}
+impl<T:PartialOrd> PartialOrd for Box<T> {
+    #[inline]
+    fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering> {
+        (**self).partial_cmp(*other)
+    }
+    #[inline]
+    fn lt(&self, other: &Box<T>) -> bool { *(*self) < *(*other) }
+    #[inline]
+    fn le(&self, other: &Box<T>) -> bool { *(*self) <= *(*other) }
+    #[inline]
+    fn ge(&self, other: &Box<T>) -> bool { *(*self) >= *(*other) }
+    #[inline]
+    fn gt(&self, other: &Box<T>) -> bool { *(*self) > *(*other) }
+}
+impl<T: Ord> Ord for Box<T> {
+    #[inline]
+    fn cmp(&self, other: &Box<T>) -> Ordering { (**self).cmp(*other) }
+}
+impl<T: Eq> Eq for Box<T> {}
+
+/// Extension methods for an owning `Any` trait object
+#[unstable = "post-DST, the signature of `downcast` will change to take `Box<Self>`"]
+pub trait BoxAny {
+    /// Returns the boxed value if it is of type `T`, or
+    /// `Err(Self)` if it isn't.
+    fn downcast<T: 'static>(self) -> Result<Box<T>, Self>;
+
+    /// Deprecated; this method has been renamed to `downcast`.
+    #[deprecated = "use downcast instead"]
+    fn move<T: 'static>(self) -> Result<Box<T>, Self> {
+        self.downcast::<T>()
+    }
+}
+
+impl BoxAny for Box<Any> {
+    #[inline]
+    fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
+        if self.is::<T>() {
+            unsafe {
+                // Get the raw representation of the trait object
+                let to: TraitObject =
+                    *mem::transmute::<&Box<Any>, &TraitObject>(&self);
+
+                // Prevent destructor on self being run
+                intrinsics::forget(self);
+
+                // Extract the data pointer
+                Ok(mem::transmute(to.data))
+            }
+        } else {
+            Err(self)
+        }
+    }
+}
+
+impl<T: fmt::Show> fmt::Show for Box<T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        (**self).fmt(f)
+    }
+}
+
+impl fmt::Show for Box<Any> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        f.pad("Box<Any>")
+    }
+}
+
+#[cfg(test)]
+mod test {
+    #[test]
+    fn test_owned_clone() {
+        let a = box 5i;
+        let b: Box<int> = a.clone();
+        assert!(a == b);
+    }
+
+    #[test]
+    fn any_move() {
+        let a = box 8u as Box<Any>;
+        let b = box Test as Box<Any>;
+
+        match a.downcast::<uint>() {
+            Ok(a) => { assert!(a == box 8u); }
+            Err(..) => fail!()
+        }
+        match b.downcast::<Test>() {
+            Ok(a) => { assert!(a == box Test); }
+            Err(..) => fail!()
+        }
+
+        let a = box 8u as Box<Any>;
+        let b = box Test as Box<Any>;
+
+        assert!(a.downcast::<Box<Test>>().is_err());
+        assert!(b.downcast::<Box<uint>>().is_err());
+    }
+
+    #[test]
+    fn test_show() {
+        let a = box 8u as Box<Any>;
+        let b = box Test as Box<Any>;
+        let a_str = a.to_str();
+        let b_str = b.to_str();
+        assert_eq!(a_str.as_slice(), "Box<Any>");
+        assert_eq!(b_str.as_slice(), "Box<Any>");
+
+        let a = &8u as &Any;
+        let b = &Test as &Any;
+        let s = format!("{}", a);
+        assert_eq!(s.as_slice(), "&Any");
+        let s = format!("{}", b);
+        assert_eq!(s.as_slice(), "&Any");
+    }
+}
index 80b6cee2a9db94189d05dd1b8ba72ae2fd1185ff..6ae91f3897104bddcbf7ae9e17c64c520c5e58cd 100644 (file)
 //!
 //! Currently, there are four major definitions in this library.
 //!
-//! ## Owned pointers
+//! ## Boxed values
 //!
-//! The [`Box`](owned/index.html) type is the core owned pointer type in rust.
+//! The [`Box`](boxed/index.html) type is the core owned pointer type in rust.
 //! There can only be one owner of a `Box`, and the owner can decide to mutate
-//! the contents.
+//! the contents, which live on the heap.
 //!
 //! This type can be sent among tasks efficiently as the size of a `Box` value
 //! is just a pointer. Tree-like data structures are often built on owned
 #[cfg(test)] #[phase(plugin, link)] extern crate std;
 #[cfg(test)] #[phase(plugin, link)] extern crate log;
 
+// The deprecated name of the boxed module
+
+#[deprecated = "use boxed instead"]
+#[cfg(not(test))]
+pub use owned = boxed;
+
 // Heaps provided for low-level allocation strategies
 
 pub mod heap;
@@ -91,7 +97,7 @@
 // Primitive types using the heaps above
 
 #[cfg(not(test))]
-pub mod owned;
+pub mod boxed;
 pub mod arc;
 pub mod rc;
 
diff --git a/src/liballoc/owned.rs b/src/liballoc/owned.rs
deleted file mode 100644 (file)
index addec39..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-// Copyright 2012 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.
-
-//! A unique pointer type
-
-use core::any::{Any, AnyRefExt};
-use core::clone::Clone;
-use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
-use core::default::Default;
-use core::fmt;
-use core::intrinsics;
-use core::kinds::Send;
-use core::mem;
-use core::option::Option;
-use core::raw::TraitObject;
-use core::result::{Ok, Err, Result};
-
-/// A value that represents the global exchange heap. This is the default
-/// place that the `box` keyword allocates into when no place is supplied.
-///
-/// The following two examples are equivalent:
-///
-///     use std::owned::HEAP;
-///
-///     # struct Bar;
-///     # impl Bar { fn new(_a: int) { } }
-///     let foo = box(HEAP) Bar::new(2);
-///     let foo = box Bar::new(2);
-#[lang="exchange_heap"]
-pub static HEAP: () = ();
-
-/// A type that represents a uniquely-owned value.
-#[lang="owned_box"]
-pub struct Box<T>(*mut T);
-
-impl<T: Default> Default for Box<T> {
-    fn default() -> Box<T> { box Default::default() }
-}
-
-#[unstable]
-impl<T: Clone> Clone for Box<T> {
-    /// Return a copy of the owned box.
-    #[inline]
-    fn clone(&self) -> Box<T> { box {(**self).clone()} }
-
-    /// Perform copy-assignment from `source` by reusing the existing allocation.
-    #[inline]
-    fn clone_from(&mut self, source: &Box<T>) {
-        (**self).clone_from(&(**source));
-    }
-}
-
-// box pointers
-impl<T:PartialEq> PartialEq for Box<T> {
-    #[inline]
-    fn eq(&self, other: &Box<T>) -> bool { *(*self) == *(*other) }
-    #[inline]
-    fn ne(&self, other: &Box<T>) -> bool { *(*self) != *(*other) }
-}
-impl<T:PartialOrd> PartialOrd for Box<T> {
-    #[inline]
-    fn partial_cmp(&self, other: &Box<T>) -> Option<Ordering> {
-        (**self).partial_cmp(*other)
-    }
-    #[inline]
-    fn lt(&self, other: &Box<T>) -> bool { *(*self) < *(*other) }
-    #[inline]
-    fn le(&self, other: &Box<T>) -> bool { *(*self) <= *(*other) }
-    #[inline]
-    fn ge(&self, other: &Box<T>) -> bool { *(*self) >= *(*other) }
-    #[inline]
-    fn gt(&self, other: &Box<T>) -> bool { *(*self) > *(*other) }
-}
-impl<T: Ord> Ord for Box<T> {
-    #[inline]
-    fn cmp(&self, other: &Box<T>) -> Ordering { (**self).cmp(*other) }
-}
-impl<T: Eq> Eq for Box<T> {}
-
-/// Extension methods for an owning `Any` trait object
-pub trait AnyOwnExt {
-    /// Returns the boxed value if it is of type `T`, or
-    /// `Err(Self)` if it isn't.
-    fn move<T: 'static>(self) -> Result<Box<T>, Self>;
-}
-
-impl AnyOwnExt for Box<Any> {
-    #[inline]
-    fn move<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
-        if self.is::<T>() {
-            unsafe {
-                // Get the raw representation of the trait object
-                let to: TraitObject =
-                    *mem::transmute::<&Box<Any>, &TraitObject>(&self);
-
-                // Prevent destructor on self being run
-                intrinsics::forget(self);
-
-                // Extract the data pointer
-                Ok(mem::transmute(to.data))
-            }
-        } else {
-            Err(self)
-        }
-    }
-}
-
-/// Extension methods for an owning `Any+Send` trait object
-pub trait AnySendOwnExt {
-    /// Returns the boxed value if it is of type `T`, or
-    /// `Err(Self)` if it isn't.
-    fn move_send<T: 'static>(self) -> Result<Box<T>, Self>;
-}
-
-impl AnySendOwnExt for Box<Any+Send> {
-    #[inline]
-    fn move_send<T: 'static>(self) -> Result<Box<T>, Box<Any+Send>> {
-        if self.is::<T>() {
-            unsafe {
-                // Get the raw representation of the trait object
-                let to: TraitObject =
-                    *mem::transmute::<&Box<Any+Send>, &TraitObject>(&self);
-
-                // Prevent destructor on self being run
-                intrinsics::forget(self);
-
-                // Extract the data pointer
-                Ok(mem::transmute(to.data))
-            }
-        } else {
-            Err(self)
-        }
-    }
-}
-
-impl<T: fmt::Show> fmt::Show for Box<T> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        (**self).fmt(f)
-    }
-}
-
-impl fmt::Show for Box<Any> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        f.pad("Box<Any>")
-    }
-}
-
-#[cfg(test)]
-mod test {
-    #[test]
-    fn test_owned_clone() {
-        let a = box 5i;
-        let b: Box<int> = a.clone();
-        assert!(a == b);
-    }
-
-    #[test]
-    fn any_move() {
-        let a = box 8u as Box<Any>;
-        let b = box Test as Box<Any>;
-
-        match a.move::<uint>() {
-            Ok(a) => { assert!(a == box 8u); }
-            Err(..) => fail!()
-        }
-        match b.move::<Test>() {
-            Ok(a) => { assert!(a == box Test); }
-            Err(..) => fail!()
-        }
-
-        let a = box 8u as Box<Any>;
-        let b = box Test as Box<Any>;
-
-        assert!(a.move::<Box<Test>>().is_err());
-        assert!(b.move::<Box<uint>>().is_err());
-    }
-
-    #[test]
-    fn test_show() {
-        let a = box 8u as Box<Any>;
-        let b = box Test as Box<Any>;
-        let a_str = a.to_str();
-        let b_str = b.to_str();
-        assert_eq!(a_str.as_slice(), "Box<Any>");
-        assert_eq!(b_str.as_slice(), "Box<Any>");
-
-        let a = &8u as &Any;
-        let b = &Test as &Any;
-        let s = format!("{}", a);
-        assert_eq!(s.as_slice(), "&Any");
-        let s = format!("{}", b);
-        assert_eq!(s.as_slice(), "&Any");
-    }
-}
index 2d138b1a1895f3d45406c15d00dbc9bdf5c9c421..6ee68f74438fecc08460858d83abdcb1ea589310 100644 (file)
@@ -20,7 +20,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::fmt;
 use core::fmt::Show;
 
index ed2d67388766700ebd3b99ddf4ec9d739d05ea88..226dd5a2356c93415db75bc49d2aa0b7d6a7b22c 100644 (file)
@@ -23,7 +23,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::default::Default;
 use core::fmt;
 use core::iter;
index e3d1c9a3216bc8252c7110d079b5b6b6f7ff2799..357383207150ea047c70ca8989eadc453f40a171 100644 (file)
@@ -65,7 +65,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use alloc::rc::Rc;
 use core::intrinsics::TypeId;
 use core::mem;
index 1451bf9d7c7bcedd84b306f518d5494af50286e0..bb596530d4ab85008371f417132b13bc7ea86c23 100644 (file)
@@ -14,7 +14,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::default::Default;
 use core::fmt;
 use core::fmt::Show;
index 9b6355e121bea459af7c7e4336e3e7396256648d..29ec85590b32044a14d900e7a92ffae09bc1230f 100644 (file)
@@ -12,7 +12,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::default::Default;
 use core::mem::zeroed;
 use core::mem;
index 355ee7c7a16f010c48b2f954b4d58eef7e2adbcb..51b5d0aded800b2fd6ec3fbc0d9c72856e3fb693 100644 (file)
 use ty::Unsafe;
 
 /// A mutable memory location that admits only `Copy` data.
+#[unstable = "likely to be renamed; otherwise stable"]
 pub struct Cell<T> {
     value: Unsafe<T>,
     noshare: marker::NoShare,
 }
 
+#[stable]
 impl<T:Copy> Cell<T> {
     /// Creates a new `Cell` containing the given value.
     pub fn new(value: T) -> Cell<T> {
@@ -192,13 +194,14 @@ pub fn set(&self, value: T) {
     }
 }
 
-#[unstable]
+#[unstable = "waiting for `Clone` trait to become stable"]
 impl<T:Copy> Clone for Cell<T> {
     fn clone(&self) -> Cell<T> {
         Cell::new(self.get())
     }
 }
 
+#[unstable = "waiting for `PartialEq` trait to become stable"]
 impl<T:PartialEq + Copy> PartialEq for Cell<T> {
     fn eq(&self, other: &Cell<T>) -> bool {
         self.get() == other.get()
@@ -206,6 +209,7 @@ fn eq(&self, other: &Cell<T>) -> bool {
 }
 
 /// A mutable memory location with dynamically checked borrow rules
+#[unstable = "likely to be renamed; otherwise stable"]
 pub struct RefCell<T> {
     value: Unsafe<T>,
     borrow: Cell<BorrowFlag>,
@@ -221,6 +225,7 @@ pub struct RefCell<T> {
 
 impl<T> RefCell<T> {
     /// Create a new `RefCell` containing `value`
+    #[stable]
     pub fn new(value: T) -> RefCell<T> {
         RefCell {
             value: Unsafe::new(value),
@@ -231,6 +236,7 @@ pub fn new(value: T) -> RefCell<T> {
     }
 
     /// Consumes the `RefCell`, returning the wrapped value.
+    #[unstable = "may be renamed, depending on global conventions"]
     pub fn unwrap(self) -> T {
         debug_assert!(self.borrow.get() == UNUSED);
         unsafe{self.value.unwrap()}
@@ -242,6 +248,7 @@ pub fn unwrap(self) -> T {
     /// immutable borrows can be taken out at the same time.
     ///
     /// Returns `None` if the value is currently mutably borrowed.
+    #[unstable = "may be renamed, depending on global conventions"]
     pub fn try_borrow<'a>(&'a self) -> Option<Ref<'a, T>> {
         match self.borrow.get() {
             WRITING => None,
@@ -260,6 +267,7 @@ pub fn try_borrow<'a>(&'a self) -> Option<Ref<'a, T>> {
     /// # Failure
     ///
     /// Fails if the value is currently mutably borrowed.
+    #[unstable]
     pub fn borrow<'a>(&'a self) -> Ref<'a, T> {
         match self.try_borrow() {
             Some(ptr) => ptr,
@@ -273,6 +281,7 @@ pub fn borrow<'a>(&'a self) -> Ref<'a, T> {
     /// cannot be borrowed while this borrow is active.
     ///
     /// Returns `None` if the value is currently borrowed.
+    #[unstable = "may be renamed, depending on global conventions"]
     pub fn try_borrow_mut<'a>(&'a self) -> Option<RefMut<'a, T>> {
         match self.borrow.get() {
             UNUSED => {
@@ -291,6 +300,7 @@ pub fn try_borrow_mut<'a>(&'a self) -> Option<RefMut<'a, T>> {
     /// # Failure
     ///
     /// Fails if the value is currently borrowed.
+    #[unstable]
     pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T> {
         match self.try_borrow_mut() {
             Some(ptr) => ptr,
@@ -299,13 +309,14 @@ pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T> {
     }
 }
 
-#[unstable]
+#[unstable = "waiting for `Clone` to become stable"]
 impl<T: Clone> Clone for RefCell<T> {
     fn clone(&self) -> RefCell<T> {
         RefCell::new(self.borrow().clone())
     }
 }
 
+#[unstable = "waiting for `PartialEq` to become stable"]
 impl<T: PartialEq> PartialEq for RefCell<T> {
     fn eq(&self, other: &RefCell<T>) -> bool {
         *self.borrow() == *other.borrow()
@@ -313,6 +324,7 @@ fn eq(&self, other: &RefCell<T>) -> bool {
 }
 
 /// Wraps a borrowed reference to a value in a `RefCell` box.
+#[unstable]
 pub struct Ref<'b, T> {
     // FIXME #12808: strange name to try to avoid interfering with
     // field accesses of the contained type via Deref
@@ -320,6 +332,7 @@ pub struct Ref<'b, T> {
 }
 
 #[unsafe_destructor]
+#[unstable]
 impl<'b, T> Drop for Ref<'b, T> {
     fn drop(&mut self) {
         let borrow = self._parent.borrow.get();
@@ -328,6 +341,7 @@ fn drop(&mut self) {
     }
 }
 
+#[unstable = "waiting for `Deref` to become stable"]
 impl<'b, T> Deref<T> for Ref<'b, T> {
     #[inline]
     fn deref<'a>(&'a self) -> &'a T {
@@ -341,7 +355,7 @@ fn deref<'a>(&'a self) -> &'a T {
 ///
 /// A `Clone` implementation would interfere with the widespread
 /// use of `r.borrow().clone()` to clone the contents of a `RefCell`.
-#[experimental]
+#[experimental = "likely to be moved to a method, pending language changes"]
 pub fn clone_ref<'b, T>(orig: &Ref<'b, T>) -> Ref<'b, T> {
     // Since this Ref exists, we know the borrow flag
     // is not set to WRITING.
@@ -355,6 +369,7 @@ pub fn clone_ref<'b, T>(orig: &Ref<'b, T>) -> Ref<'b, T> {
 }
 
 /// Wraps a mutable borrowed reference to a value in a `RefCell` box.
+#[unstable]
 pub struct RefMut<'b, T> {
     // FIXME #12808: strange name to try to avoid interfering with
     // field accesses of the contained type via Deref
@@ -362,6 +377,7 @@ pub struct RefMut<'b, T> {
 }
 
 #[unsafe_destructor]
+#[unstable]
 impl<'b, T> Drop for RefMut<'b, T> {
     fn drop(&mut self) {
         let borrow = self._parent.borrow.get();
@@ -370,6 +386,7 @@ fn drop(&mut self) {
     }
 }
 
+#[unstable = "waiting for `Deref` to become stable"]
 impl<'b, T> Deref<T> for RefMut<'b, T> {
     #[inline]
     fn deref<'a>(&'a self) -> &'a T {
@@ -377,6 +394,7 @@ fn deref<'a>(&'a self) -> &'a T {
     }
 }
 
+#[unstable = "waiting for `DerefMut` to become stable"]
 impl<'b, T> DerefMut<T> for RefMut<'b, T> {
     #[inline]
     fn deref_mut<'a>(&'a mut self) -> &'a mut T {
index 3c0a4aae251dbd90506a5af37a829274eec771e1..af6de0cf605a204119deefbe2ebf8b683d8c2cb1 100644 (file)
@@ -45,7 +45,7 @@ pub fn clone() -> Option<Vec<Vec<u8>>> { imp::clone() }
 mod imp {
     use core::prelude::*;
 
-    use alloc::owned::Box;
+    use alloc::boxed::Box;
     use collections::vec::Vec;
     use core::mem;
     use core::slice;
index dcba7fb7cb6a6255d51b295c6c9f2d6d3e2d2d17..1faf492e498ace09860dd8fc0ccd65091c892a82 100644 (file)
@@ -14,7 +14,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use collections::vec::Vec;
 use core::atomics;
 use core::mem;
index c830b2e122ec03c549d06e0d1e10731b55c1ad2e..0b611381aa2de90f7b12b29d62e6c663643218e8 100644 (file)
@@ -37,7 +37,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::any::Any;
 
 use task::{Task, BlockedTask, TaskOpts};
index 7fe9dbc6d4ff554d81cbe5a3e375d40ed988de38..bdb1c60b6d6f8db7acedcbb32d2aeb0d1ffe3f49 100644 (file)
@@ -10,7 +10,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use local_ptr;
 use task::Task;
 
index d4c87e9fc05c14e458ff110237360935b2baa28b..ace53478d0a034b5b2aa329318b1d2a0f31ef710 100644 (file)
@@ -40,7 +40,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use collections::vec::Vec;
 use core::kinds::marker;
 use core::mem;
index 813ea0f30f38b71afbb3655ccc7d82646ca1840c..c94e5c6187b3a93e308801b3ea0feb21c64a617e 100644 (file)
@@ -20,7 +20,7 @@
 use core::prelude::*;
 
 use core::mem;
-use alloc::owned::Box;
+use alloc::boxed::Box;
 
 #[cfg(windows)]               // mingw-w32 doesn't like thread_local things
 #[cfg(target_os = "android")] // see #10686
@@ -86,7 +86,7 @@ pub unsafe fn borrow<T>() -> Borrowed<T> {
 pub mod compiled {
     use core::prelude::*;
 
-    use alloc::owned::Box;
+    use alloc::boxed::Box;
     use core::mem;
 
     #[cfg(test)]
@@ -237,7 +237,7 @@ pub unsafe fn try_unsafe_borrow<T>() -> Option<*mut T> {
 pub mod native {
     use core::prelude::*;
 
-    use alloc::owned::Box;
+    use alloc::boxed::Box;
     use core::mem;
     use core::ptr;
     use tls = thread_local_storage;
index 7a91cca6265a0a782e29492eca9d0a69f7ed1e00..343b911fb83f3d775e9312fa34b7ef3794d82fa0 100644 (file)
@@ -11,7 +11,7 @@
 //! The EventLoop and internal synchronous I/O interface.
 
 use core::prelude::*;
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use collections::string::String;
 use collections::vec::Vec;
 use core::fmt;
index 8e637207d2209c07879c581112e507c33c68296b..0eacd40f01cee052d45bcf48e9fe47cfa19a21b2 100644 (file)
@@ -56,7 +56,7 @@
 #[lang = "stack_exhausted"]
 extern fn stack_exhausted() {
     use core::prelude::*;
-    use alloc::owned::Box;
+    use alloc::boxed::Box;
     use local::Local;
     use task::Task;
     use core::intrinsics;
index 59401a8b66604f0568c80a293bf0421e9ed1ecee..78c32889277b2230d131838f694b24933fc789f5 100644 (file)
@@ -16,7 +16,7 @@
 use core::prelude::*;
 
 use alloc::arc::Arc;
-use alloc::owned::{AnyOwnExt, Box};
+use alloc::boxed::{BoxAny, Box};
 use core::any::Any;
 use core::atomics::{AtomicUint, SeqCst};
 use core::iter::Take;
@@ -376,7 +376,7 @@ pub fn maybe_take_runtime<T: 'static>(&mut self) -> Option<Box<T>> {
         unsafe {
             let imp = self.imp.take_unwrap();
             let vtable = mem::transmute::<_, &raw::TraitObject>(&imp).vtable;
-            match imp.wrap().move::<T>() {
+            match imp.wrap().downcast::<T>() {
                 Ok(t) => Some(t),
                 Err(t) => {
                     let data = mem::transmute::<_, raw::TraitObject>(t).data;
index 59784328cdb50c02448a3893b1a4776e947415e3..7bc991cf72f3a85b98fa3595cda8a5812168500d 100644 (file)
@@ -18,7 +18,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::mem;
 use core::uint;
 use libc;
@@ -147,7 +147,7 @@ fn drop(&mut self) {
 mod imp {
     use core::prelude::*;
 
-    use alloc::owned::Box;
+    use alloc::boxed::Box;
     use core::cmp;
     use core::mem;
     use core::ptr;
@@ -215,7 +215,7 @@ fn CreateThread(lpThreadAttributes: LPSECURITY_ATTRIBUTES,
 mod imp {
     use core::prelude::*;
 
-    use alloc::owned::Box;
+    use alloc::boxed::Box;
     use core::cmp;
     use core::mem;
     use core::ptr;
index 18688cbcc64ca788668db469d231b520b562533d..f26cccdd3ed9085fa372a8aa97f8f0a6a6a284b5 100644 (file)
@@ -59,7 +59,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use collections::string::String;
 use collections::vec::Vec;
 use core::any::Any;
index a02402271d08383bdc76faa2ebd942459e7f444e..45301737adb3dad902371e20052671c92773552e 100644 (file)
@@ -45,7 +45,7 @@
 use mem;
 use ops::Drop;
 use option::{Some, None, Option};
-use owned::Box;
+use boxed::Box;
 use ptr;
 use result::{Ok, Err};
 
index 47ff85e2806d562caf77f6e81d12dc1255e36e9f..8c709d20d1904d3ee25e9ba770059bd33de2e770 100644 (file)
@@ -10,7 +10,7 @@
 
 #![experimental]
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use any::{Any, AnyRefExt};
 use fmt;
 use io::{Writer, IoResult};
index ed183cbf3bc2191dac321c7a6f582144080f4d9c..ff2b35160a151b42b4adf01e06f09312f89dd63d 100644 (file)
@@ -62,7 +62,7 @@
 use kinds::Send;
 use libc;
 use option::{Some, None, Option};
-use owned::Box;
+use boxed::Box;
 use path::{Path, GenericPath};
 use path;
 use result::{Err, Ok};
index 4ef2e51fcf0b6a855bfa00d28eb770c98dd787de..db4df7a8a6f10ecf3525a8ba8a77fb40e36ddd77 100644 (file)
@@ -229,7 +229,7 @@ fn file_product(p: &Path) -> IoResult<u32> {
 use ops::{BitOr, BitAnd, Sub, Not};
 use option::{Option, Some, None};
 use os;
-use owned::Box;
+use boxed::Box;
 use result::{Ok, Err, Result};
 use rt::rtio;
 use slice::{Vector, MutableVector, ImmutableVector};
index 49322098348ff830bd0fb09528de975bb3d20158..642654ba6ed815252e62df30ebb2ac6729061235 100644 (file)
@@ -29,7 +29,7 @@
 use from_str::FromStr;
 use kinds::Send;
 use option::{None, Some, Option};
-use owned::Box;
+use boxed::Box;
 use rt::rtio::{IoFactory, LocalIo, RtioSocket, RtioTcpListener};
 use rt::rtio::{RtioTcpAcceptor, RtioTcpStream};
 use rt::rtio;
index 21903eb26439cc30c79b60d90acdd8ff29bf51a9..5f7563e7467ba6644e9399dac350f2d3b82c1c03 100644 (file)
@@ -19,7 +19,7 @@
 use io::net::ip::{SocketAddr, IpAddr};
 use io::{Reader, Writer, IoResult, IoError};
 use kinds::Send;
-use owned::Box;
+use boxed::Box;
 use option::Option;
 use result::{Ok, Err};
 use rt::rtio::{RtioSocket, RtioUdpSocket, IoFactory, LocalIo};
index c5ddda9945de1f82b86b287b468fba37647228df..5e7c421497772faa7f7244326a6a238c3ee10b4e 100644 (file)
@@ -30,7 +30,7 @@
 use clone::Clone;
 use io::{Listener, Acceptor, Reader, Writer, IoResult, IoError};
 use kinds::Send;
-use owned::Box;
+use boxed::Box;
 use rt::rtio::{IoFactory, LocalIo, RtioUnixListener};
 use rt::rtio::{RtioUnixAcceptor, RtioPipe};
 
index a968f41a91563ce9c7d7a66bf7a551fa9db94f13..c476a99fee9dc465d3d31b23ec40ef775c29a26d 100644 (file)
@@ -20,7 +20,7 @@
 use io::{IoResult, IoError};
 use libc;
 use os;
-use owned::Box;
+use boxed::Box;
 use rt::rtio::{RtioPipe, LocalIo};
 
 /// A synchronous, in-memory pipe.
index 6ef730237795cd243d0395c737a11b74943ff06d..07574b726457985af06b1f217403493d5e7ac431 100644 (file)
@@ -21,7 +21,7 @@
 use io;
 use libc;
 use mem;
-use owned::Box;
+use boxed::Box;
 use rt::rtio::{RtioProcess, ProcessConfig, IoFactory, LocalIo};
 use rt::rtio;
 use c_str::CString;
index 4a7655a63ce8c257a27f6a482173de26bc3bc82b..d46f437cddd50a500badf5021657b7528866b4b7 100644 (file)
@@ -26,7 +26,7 @@
 use kinds::Send;
 use mem::drop;
 use option::{Some, None};
-use owned::Box;
+use boxed::Box;
 use result::{Ok, Err};
 use rt::rtio::{IoFactory, LocalIo, RtioSignal, Callback};
 use slice::ImmutableVector;
index cdd083202e085217d3bf74583694dd3d245b11b3..45c084b3459613370e5aeac03d2f00fb4e73410a 100644 (file)
@@ -35,7 +35,7 @@
 use kinds::Send;
 use libc;
 use option::{Option, Some, None};
-use owned::Box;
+use boxed::Box;
 use result::{Ok, Err};
 use rt;
 use rt::local::Local;
index 432461c46063493f4e471d5b42fb29bb0b1d2f07..1c9e428dcad82e897897ddcc4f40ba6c2c3a913b 100644 (file)
@@ -20,7 +20,7 @@
 use comm::{Receiver, Sender, channel};
 use io::{IoResult, IoError};
 use kinds::Send;
-use owned::Box;
+use boxed::Box;
 use rt::rtio::{IoFactory, LocalIo, RtioTimer, Callback};
 
 /// A synchronous timer object
index 2acf12b76c00adea15f127673a8277222759d125..e928323030c4f5f34ca5e485af1ae8a9eed1d27a 100644 (file)
@@ -13,7 +13,7 @@
 use prelude::*;
 use cmp;
 use io;
-use owned::Box;
+use boxed::Box;
 use slice::bytes::MutableByteVector;
 
 /// Wraps a `Reader`, limiting the number of bytes that can be read from it.
@@ -263,7 +263,7 @@ fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> {
 mod test {
     use io::{MemReader, MemWriter, BufReader};
     use io;
-    use owned::Box;
+    use boxed::Box;
     use super::*;
     use prelude::*;
 
index 14782cafce34781a6aed1cc8b3b3fed67368bd0b..34c1530f96ca1e72fb5a337d3d8b5c760395ca6f 100644 (file)
 #[cfg(test)] pub use realstd::ops;
 #[cfg(test)] pub use realstd::cmp;
 #[cfg(test)] pub use realstd::ty;
-#[cfg(test)] pub use realstd::owned;
+#[cfg(test)] pub use realstd::boxed;
 #[cfg(test)] pub use realstd::gc;
 
 
 pub use core::result;
 pub use core::option;
 
-pub use alloc::owned;
+pub use alloc::boxed;
+#[deprecated = "use boxed instead"]
+pub use owned = boxed;
+
 pub use alloc::rc;
 
 pub use core_collections::slice;
index 21f80777293125902b5aaeb9092e0ef621016d65..a20ac112ac52cc7270faf777d9de12bbf90a357d 100644 (file)
@@ -72,7 +72,7 @@
 #[doc(no_inline)] pub use num::{Num, NumCast, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv};
 #[doc(no_inline)] pub use num::{Signed, Unsigned, Primitive, Int, Float};
 #[doc(no_inline)] pub use num::{FloatMath, ToPrimitive, FromPrimitive};
-#[doc(no_inline)] pub use owned::Box;
+#[doc(no_inline)] pub use boxed::Box;
 #[doc(no_inline)] pub use path::{GenericPath, Path, PosixPath, WindowsPath};
 #[doc(no_inline)] pub use ptr::RawPtr;
 #[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek};
index 72cc596085e075ff7fbd7dd6b7f1f3dcc6528c1a..d7af92024eb5e6fe753f16e34885543086c4433a 100644 (file)
@@ -98,7 +98,7 @@
 use io::{Writer, stdio};
 use kinds::{Send, marker};
 use option::{None, Some, Option};
-use owned::Box;
+use boxed::Box;
 use result::Result;
 use rt::local::Local;
 use rt::task;
@@ -374,7 +374,7 @@ pub fn failing() -> bool {
 #[cfg(test)]
 mod test {
     use any::{Any, AnyRefExt};
-    use owned::AnyOwnExt;
+    use boxed::BoxAny;
     use result;
     use result::{Ok, Err};
     use str::StrAllocating;
@@ -578,7 +578,7 @@ fn test_try_fail_message_static_str() {
             Err(e) => {
                 type T = &'static str;
                 assert!(e.is::<T>());
-                assert_eq!(*e.move::<T>().unwrap(), "static string");
+                assert_eq!(*e.downcast::<T>().unwrap(), "static string");
             }
             Ok(()) => fail!()
         }
@@ -592,7 +592,7 @@ fn test_try_fail_message_owned_str() {
             Err(e) => {
                 type T = String;
                 assert!(e.is::<T>());
-                assert_eq!(*e.move::<T>().unwrap(), "owned string".to_string());
+                assert_eq!(*e.downcast::<T>().unwrap(), "owned string".to_string());
             }
             Ok(()) => fail!()
         }
@@ -606,9 +606,9 @@ fn test_try_fail_message_any() {
             Err(e) => {
                 type T = Box<Any + Send>;
                 assert!(e.is::<T>());
-                let any = e.move::<T>().unwrap();
+                let any = e.downcast::<T>().unwrap();
                 assert!(any.is::<u16>());
-                assert_eq!(*any.move::<u16>().unwrap(), 413u16);
+                assert_eq!(*any.downcast::<u16>().unwrap(), 413u16);
             }
             Ok(()) => fail!()
         }
index 195efb844a78328fe3bc0535cece16307d057492..0be124ad58408d6f9cf375af5fb6f83021f0853c 100644 (file)
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::mem;
 
 pub use core::atomics::{AtomicBool, AtomicInt, AtomicUint, AtomicPtr};
index 6c09a021c4338212efe8056a38efd07f76f6229e..e9a303634fe37c0ac34dd26186862f7582407555 100644 (file)
 use core::prelude::*;
 
 use alloc::arc::Arc;
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::cell::Cell;
 use core::kinds::marker;
 use core::mem;
index 742686069e283531461e68cd7852e9f6d88bbc58..c9782db5c24b66e2a1de511c0e69ae99344a3b8c 100644 (file)
@@ -34,7 +34,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::mem;
 use rustrt::local::Local;
 use rustrt::task::{Task, BlockedTask};
index 230bca624f5a7f61ae80f9c2a4ef0f74f8b6b316..737a4bfe29916fab400b184b8877d985bc38f7ab 100644 (file)
@@ -54,7 +54,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::cell::Cell;
 use core::kinds::marker;
 use core::mem;
index 5ad4dea5d2a89bc52df8a319d19cdecb1703ca94..d13b2c32978c41e4d11cdf26ea7af4dca1e3cb7b 100644 (file)
@@ -20,7 +20,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::cmp;
 use core::int;
 use rustrt::local::Local;
index 6f337f1730950d3cfb9288d32e76c028fe4c1fa4..9747c207a22612fdce2a6fa71f8b6f8dc23389a3 100644 (file)
@@ -19,7 +19,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::cmp;
 use core::int;
 use rustrt::local::Local;
index 4d54df2fc19e58e5544efc09fb9340895bdccd4f..cc3c2197c13f03368adf77a6e75647e5463c07a1 100644 (file)
@@ -35,7 +35,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use collections::Vec;
 use collections::Collection;
 use core::mem;
index 8d2192aeb537ed19b823b1ed62eeebb34774fd4d..913a58010d496b9db4c010e393a048a93ce07056 100644 (file)
@@ -54,7 +54,7 @@
 
 use alloc::arc::Arc;
 use alloc::heap::{allocate, deallocate};
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use collections::Vec;
 use core::kinds::marker;
 use core::mem::{forget, min_align_of, size_of, transmute};
index ecd37e68880555dba3a43d41d955d4762e71f685..759695fe5b6dd2520d691861f7810c6065e88748 100644 (file)
@@ -42,7 +42,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::mem;
 use core::ty::Unsafe;
 
index a10ec7458690abcbf20e68bd12c2e4730dea4f76..990d743465d6998e483a51f633adfe745de1b89d 100644 (file)
@@ -59,7 +59,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::atomics;
 use core::kinds::marker;
 use core::mem;
index 2834d404c1879e7de75b7b45577edbfbfcd01d7e..cf4d3222ed0ed8527636ab11f450b7794e13c088 100644 (file)
@@ -37,7 +37,7 @@
 
 use core::prelude::*;
 
-use alloc::owned::Box;
+use alloc::boxed::Box;
 use core::mem;
 use core::ty::Unsafe;
 
index 383a0ac46193fc7e8f58360b1efc3605180fe0e7..602ffe2680b04a7c7b79e7263d05810c0bc7d573 100644 (file)
@@ -14,7 +14,7 @@
 // Tests that the new `box` syntax works with unique pointers and GC pointers.
 
 use std::gc::{Gc, GC};
-use std::owned::{Box, HEAP};
+use std::boxed::{Box, HEAP};
 
 pub fn main() {
     let x: Gc<int> = box(HEAP) 2;  //~ ERROR mismatched types
index b16bef3fc9902c168b676ffb4bc5d5dce9288268..f61a8837e2c7c7dfe31eeb9fb92b6791d465cd73 100644 (file)
@@ -14,7 +14,7 @@
 // Tests that the new `box` syntax works with unique pointers and GC pointers.
 
 use std::gc::{Gc, GC};
-use std::owned::{Box, HEAP};
+use std::boxed::{Box, HEAP};
 
 struct Structure {
     x: int,
@@ -33,4 +33,3 @@ pub fn main() {
     let c = box()(3i + 4);
     let d = box(GC)(5i + 6);
 }
-
index ae4623c6e66eb3b050c8a2a1645b6652c5a67a2d..3a1cc0331a3e6c04ef39c12cfd896361f2660dab 100644 (file)
@@ -10,7 +10,7 @@
 
 // Make sure the destructor is run for unit-like structs.
 
-use std::owned::AnyOwnExt;
+use std::boxed::BoxAny;
 use std::task;
 
 struct Foo;
@@ -26,6 +26,6 @@ pub fn main() {
         let _b = Foo;
     });
 
-    let s = x.unwrap_err().move::<&'static str>().unwrap();
+    let s = x.unwrap_err().downcast::<&'static str>().unwrap();
     assert_eq!(s.as_slice(), "This failure should happen.");
 }