File tree 3 files changed +10
-14
lines changed
3 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ impl<T : ?Sized> Box<T> {
116
116
/// of `T` and releases memory. Since the way `Box` allocates and
117
117
/// releases memory is unspecified, the only valid pointer to pass
118
118
/// to this function is the one taken from another `Box` with
119
- /// `boxed ::into_raw` function.
119
+ /// `Box ::into_raw` function.
120
120
///
121
121
/// Function is unsafe, because improper use of this function may
122
122
/// lead to memory problems like double-free, for example if the
@@ -140,10 +140,8 @@ impl<T : ?Sized> Box<T> {
140
140
/// # Examples
141
141
/// ```
142
142
/// # #![feature(box_raw)]
143
- /// use std::boxed;
144
- ///
145
143
/// let seventeen = Box::new(17u32);
146
- /// let raw = boxed ::into_raw(seventeen);
144
+ /// let raw = Box ::into_raw(seventeen);
147
145
/// let boxed_again = unsafe { Box::from_raw(raw) };
148
146
/// ```
149
147
#[ unstable( feature = "box_raw" , reason = "may be renamed" ) ]
Original file line number Diff line number Diff line change @@ -76,9 +76,9 @@ fn deref() {
76
76
77
77
#[ test]
78
78
fn raw_sized ( ) {
79
+ let x = Box :: new ( 17 ) ;
80
+ let p = Box :: into_raw ( x) ;
79
81
unsafe {
80
- let x = Box :: new ( 17 ) ;
81
- let p = boxed:: into_raw ( x) ;
82
82
assert_eq ! ( 17 , * p) ;
83
83
* p = 19 ;
84
84
let y = Box :: from_raw ( p) ;
@@ -105,9 +105,9 @@ fn raw_trait() {
105
105
}
106
106
}
107
107
108
+ let x: Box < Foo > = Box :: new ( Bar ( 17 ) ) ;
109
+ let p = Box :: into_raw ( x) ;
108
110
unsafe {
109
- let x: Box < Foo > = Box :: new ( Bar ( 17 ) ) ;
110
- let p = boxed:: into_raw ( x) ;
111
111
assert_eq ! ( 17 , ( * p) . get( ) ) ;
112
112
( * p) . set ( 19 ) ;
113
113
let y: Box < Foo > = Box :: from_raw ( p) ;
Original file line number Diff line number Diff line change 50
50
//!
51
51
//! ```
52
52
//! # #![feature(box_raw)]
53
- //! use std::boxed;
53
+ //! let my_speed: Box<i32> = Box::new(88);
54
+ //! let my_speed: *mut i32 = Box::into_raw(my_speed);
54
55
//!
56
+ //! // By taking ownership of the original `Box<T>` though
57
+ //! // we are obligated to put it together later to be destroyed.
55
58
//! unsafe {
56
- //! let my_speed: Box<i32> = Box::new(88);
57
- //! let my_speed: *mut i32 = boxed::into_raw(my_speed);
58
- //!
59
- //! // By taking ownership of the original `Box<T>` though
60
- //! // we are obligated to put it together later to be destroyed.
61
59
//! drop(Box::from_raw(my_speed));
62
60
//! }
63
61
//! ```
You can’t perform that action at this time.
0 commit comments