]> git.lizzy.rs Git - rust.git/commitdiff
Use Box::into_raw rather than the deprecated boxed::into_raw in tests and documentation.
authorMs2ger <ms2ger@gmail.com>
Fri, 26 Jun 2015 20:29:40 +0000 (22:29 +0200)
committerMs2ger <ms2ger@gmail.com>
Fri, 26 Jun 2015 20:29:40 +0000 (22:29 +0200)
src/liballoc/boxed.rs
src/liballoc/boxed_test.rs
src/libcore/ptr.rs

index 1039756363e9fa1aa6a05ed1a9f7f30720a19488..c941629b871ef418566ee87c4dda4ef4ba3bac7d 100644 (file)
@@ -116,7 +116,7 @@ impl<T : ?Sized> Box<T> {
     /// of `T` and releases memory. Since the way `Box` allocates and
     /// releases memory is unspecified, the only valid pointer to pass
     /// to this function is the one taken from another `Box` with
-    /// `boxed::into_raw` function.
+    /// `Box::into_raw` function.
     ///
     /// Function is unsafe, because improper use of this function may
     /// lead to memory problems like double-free, for example if the
@@ -140,10 +140,8 @@ pub unsafe fn from_raw(raw: *mut T) -> Self {
     /// # Examples
     /// ```
     /// # #![feature(box_raw)]
-    /// use std::boxed;
-    ///
     /// let seventeen = Box::new(17u32);
-    /// let raw = boxed::into_raw(seventeen);
+    /// let raw = Box::into_raw(seventeen);
     /// let boxed_again = unsafe { Box::from_raw(raw) };
     /// ```
     #[unstable(feature = "box_raw", reason = "may be renamed")]
index fc44ac4eac628b2eba405276caedb542f5d49bff..2ef23b26a56a739549562c57ef71f521dab72063 100644 (file)
@@ -76,9 +76,9 @@ fn homura<T: Deref<Target=i32>>(_: T) { }
 
 #[test]
 fn raw_sized() {
+    let x = Box::new(17);
+    let p = Box::into_raw(x);
     unsafe {
-        let x = Box::new(17);
-        let p = boxed::into_raw(x);
         assert_eq!(17, *p);
         *p = 19;
         let y = Box::from_raw(p);
@@ -105,9 +105,9 @@ fn set(&mut self, value: u32) {
         }
     }
 
+    let x: Box<Foo> = Box::new(Bar(17));
+    let p = Box::into_raw(x);
     unsafe {
-        let x: Box<Foo> = Box::new(Bar(17));
-        let p = boxed::into_raw(x);
         assert_eq!(17, (*p).get());
         (*p).set(19);
         let y: Box<Foo> = Box::from_raw(p);
index f2792a525d66b311f3fcdde63fe71af580b2642e..7b33a41f9556a0481db8ebdec8dcddfafbf78324 100644 (file)
 //!
 //! ```
 //! # #![feature(box_raw)]
-//! use std::boxed;
+//! let my_speed: Box<i32> = Box::new(88);
+//! let my_speed: *mut i32 = Box::into_raw(my_speed);
 //!
+//! // By taking ownership of the original `Box<T>` though
+//! // we are obligated to put it together later to be destroyed.
 //! unsafe {
-//!     let my_speed: Box<i32> = Box::new(88);
-//!     let my_speed: *mut i32 = boxed::into_raw(my_speed);
-//!
-//!     // By taking ownership of the original `Box<T>` though
-//!     // we are obligated to put it together later to be destroyed.
 //!     drop(Box::from_raw(my_speed));
 //! }
 //! ```