diff options
| author | Taylor Cramer <cramertj@google.com> | 2018-12-18 10:25:02 -0800 |
|---|---|---|
| committer | Taylor Cramer <cramertj@google.com> | 2018-12-21 20:42:50 -0800 |
| commit | 684fe9a6b2b39e6b8a1089eecd0334ef484fcc56 (patch) | |
| tree | 2bc0946e85c1264b3c63b198c705ce143905e594 | |
| parent | 3005bf360d11dbda5d32b9b75647df07bfa1372d (diff) | |
| download | rust-684fe9a6b2b39e6b8a1089eecd0334ef484fcc56.tar.gz rust-684fe9a6b2b39e6b8a1089eecd0334ef484fcc56.zip | |
Rename Box/Arc/Rc::pinned to ::pin
| -rw-r--r-- | src/liballoc/boxed.rs | 4 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 4 | ||||
| -rw-r--r-- | src/liballoc/sync.rs | 4 | ||||
| -rw-r--r-- | src/libcore/pin.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/async-await.rs | 2 |
5 files changed, 11 insertions, 5 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 6a63bee2795..7438f3e6c9d 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -111,9 +111,11 @@ impl<T> Box<T> { box x } + /// Constructs a new `Pin<Box<T>>`. If `T` does not implement `Unpin`, then + /// `x` will be pinned in memory and unable to be moved. #[stable(feature = "pin", since = "1.33.0")] #[inline(always)] - pub fn pinned(x: T) -> Pin<Box<T>> { + pub fn pin(x: T) -> Pin<Box<T>> { (box x).into() } } diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index a8574e82c27..14cbb204f5f 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -325,8 +325,10 @@ impl<T> Rc<T> { } } + /// Constructs a new `Pin<Rc<T>>`. If `T` does not implement `Unpin`, then + /// `value` will be pinned in memory and unable to be moved. #[stable(feature = "pin", since = "1.33.0")] - pub fn pinned(value: T) -> Pin<Rc<T>> { + pub fn pin(value: T) -> Pin<Rc<T>> { unsafe { Pin::new_unchecked(Rc::new(value)) } } diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index ac709a15aaa..c1a1e6f1591 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -303,8 +303,10 @@ impl<T> Arc<T> { Arc { ptr: Box::into_raw_non_null(x), phantom: PhantomData } } + /// Constructs a new `Pin<Arc<T>>`. If `T` does not implement `Unpin`, then + /// `data` will be pinned in memory and unable to be moved. #[stable(feature = "pin", since = "1.33.0")] - pub fn pinned(data: T) -> Pin<Arc<T>> { + pub fn pin(data: T) -> Pin<Arc<T>> { unsafe { Pin::new_unchecked(Arc::new(data)) } } diff --git a/src/libcore/pin.rs b/src/libcore/pin.rs index 9073e6e31b1..4f4ca4047e4 100644 --- a/src/libcore/pin.rs +++ b/src/libcore/pin.rs @@ -70,7 +70,7 @@ //! slice: NonNull::dangling(), //! _pin: PhantomPinned, //! }; -//! let mut boxed = Box::pinned(res); +//! let mut boxed = Box::pin(res); //! //! let slice = NonNull::from(&boxed.data); //! // we know this is safe because modifying a field doesn't move the whole struct diff --git a/src/test/run-pass/async-await.rs b/src/test/run-pass/async-await.rs index 996709fa86c..d9eb801a206 100644 --- a/src/test/run-pass/async-await.rs +++ b/src/test/run-pass/async-await.rs @@ -138,7 +138,7 @@ where F: FnOnce(u8) -> Fut, Fut: Future<Output = u8>, { - let mut fut = Box::pinned(f(9)); + let mut fut = Box::pin(f(9)); let counter = Arc::new(Counter { wakes: AtomicUsize::new(0) }); let waker = local_waker_from_nonlocal(counter.clone()); assert_eq!(0, counter.wakes.load(atomic::Ordering::SeqCst)); |
