Skip to content

Commit 9229488

Browse files
committed
Rename Box/Arc/Rc::pinned to ::pin
1 parent 80059df commit 9229488

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

src/liballoc/boxed.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ impl<T> Box<T> {
109109
box x
110110
}
111111

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.
112114
#[stable(feature = "pin", since = "1.33.0")]
113115
#[inline(always)]
114-
pub fn pinned(x: T) -> Pin<Box<T>> {
116+
pub fn pin(x: T) -> Pin<Box<T>> {
115117
(box x).into()
116118
}
117119
}

src/liballoc/rc.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,10 @@ impl<T> Rc<T> {
325325
}
326326
}
327327

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.
328330
#[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>> {
330332
unsafe { Pin::new_unchecked(Rc::new(value)) }
331333
}
332334

src/liballoc/sync.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,10 @@ impl<T> Arc<T> {
303303
Arc { ptr: Box::into_raw_non_null(x), phantom: PhantomData }
304304
}
305305

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.
306308
#[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>> {
308310
unsafe { Pin::new_unchecked(Arc::new(data)) }
309311
}
310312

src/libcore/pin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
//! slice: NonNull::dangling(),
7171
//! _pin: PhantomPinned,
7272
//! };
73-
//! let mut boxed = Box::pinned(res);
73+
//! let mut boxed = Box::pin(res);
7474
//!
7575
//! let slice = NonNull::from(&boxed.data);
7676
//! // we know this is safe because modifying a field doesn't move the whole struct

src/test/run-pass/async-await.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ where
138138
F: FnOnce(u8) -> Fut,
139139
Fut: Future<Output = u8>,
140140
{
141-
let mut fut = Box::pinned(f(9));
141+
let mut fut = Box::pin(f(9));
142142
let counter = Arc::new(Counter { wakes: AtomicUsize::new(0) });
143143
let waker = local_waker_from_nonlocal(counter.clone());
144144
assert_eq!(0, counter.wakes.load(atomic::Ordering::SeqCst));

0 commit comments

Comments
 (0)