File tree 5 files changed +11
-5
lines changed
5 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -109,9 +109,11 @@ impl<T> Box<T> {
109
109
box x
110
110
}
111
111
112
+ /// Constructs a new `Pin<Box<T>>`. If `T` does not implement `Unpin`, then
113
+ /// `x` will be pinned in memory and unable to be moved.
112
114
#[ stable( feature = "pin" , since = "1.33.0" ) ]
113
115
#[ inline( always) ]
114
- pub fn pinned ( x : T ) -> Pin < Box < T > > {
116
+ pub fn pin ( x : T ) -> Pin < Box < T > > {
115
117
( box x) . into ( )
116
118
}
117
119
}
Original file line number Diff line number Diff line change @@ -325,8 +325,10 @@ impl<T> Rc<T> {
325
325
}
326
326
}
327
327
328
+ /// Constructs a new `Pin<Rc<T>>`. If `T` does not implement `Unpin`, then
329
+ /// `value` will be pinned in memory and unable to be moved.
328
330
#[ stable( feature = "pin" , since = "1.33.0" ) ]
329
- pub fn pinned ( value : T ) -> Pin < Rc < T > > {
331
+ pub fn pin ( value : T ) -> Pin < Rc < T > > {
330
332
unsafe { Pin :: new_unchecked ( Rc :: new ( value) ) }
331
333
}
332
334
Original file line number Diff line number Diff line change @@ -303,8 +303,10 @@ impl<T> Arc<T> {
303
303
Arc { ptr : Box :: into_raw_non_null ( x) , phantom : PhantomData }
304
304
}
305
305
306
+ /// Constructs a new `Pin<Arc<T>>`. If `T` does not implement `Unpin`, then
307
+ /// `data` will be pinned in memory and unable to be moved.
306
308
#[ stable( feature = "pin" , since = "1.33.0" ) ]
307
- pub fn pinned ( data : T ) -> Pin < Arc < T > > {
309
+ pub fn pin ( data : T ) -> Pin < Arc < T > > {
308
310
unsafe { Pin :: new_unchecked ( Arc :: new ( data) ) }
309
311
}
310
312
Original file line number Diff line number Diff line change 70
70
//! slice: NonNull::dangling(),
71
71
//! _pin: PhantomPinned,
72
72
//! };
73
- //! let mut boxed = Box::pinned (res);
73
+ //! let mut boxed = Box::pin (res);
74
74
//!
75
75
//! let slice = NonNull::from(&boxed.data);
76
76
//! // we know this is safe because modifying a field doesn't move the whole struct
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ where
138
138
F : FnOnce ( u8 ) -> Fut ,
139
139
Fut : Future < Output = u8 > ,
140
140
{
141
- let mut fut = Box :: pinned ( f ( 9 ) ) ;
141
+ let mut fut = Box :: pin ( f ( 9 ) ) ;
142
142
let counter = Arc :: new ( Counter { wakes : AtomicUsize :: new ( 0 ) } ) ;
143
143
let waker = local_waker_from_nonlocal ( counter. clone ( ) ) ;
144
144
assert_eq ! ( 0 , counter. wakes. load( atomic:: Ordering :: SeqCst ) ) ;
You can’t perform that action at this time.
0 commit comments