diff options
| author | Without Boats <boats@mozilla.com> | 2018-09-01 06:12:10 +0200 |
|---|---|---|
| committer | Without Boats <boats@mozilla.com> | 2018-09-01 06:57:58 +0200 |
| commit | 974bdc80fe3214159dc30e0bbb76694900e613c0 (patch) | |
| tree | a4ce3c775b9c740ffffb0d7609fe14520fe1ec94 /src/liballoc/sync.rs | |
| parent | e6b35b0e1115f008796e8313574e4a4739b6d39d (diff) | |
| download | rust-974bdc80fe3214159dc30e0bbb76694900e613c0.tar.gz rust-974bdc80fe3214159dc30e0bbb76694900e613c0.zip | |
Update to a new pinning API.
Diffstat (limited to 'src/liballoc/sync.rs')
| -rw-r--r-- | src/liballoc/sync.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 2cd7898f4c7..d9607af1902 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -26,6 +26,7 @@ use core::intrinsics::abort; use core::mem::{self, align_of_val, size_of_val}; use core::ops::Deref; use core::ops::CoerceUnsized; +use core::pin::Pin; use core::ptr::{self, NonNull}; use core::marker::{Unsize, PhantomData}; use core::hash::{Hash, Hasher}; @@ -296,6 +297,11 @@ impl<T> Arc<T> { Arc { ptr: Box::into_raw_non_null(x), phantom: PhantomData } } + #[unstable(feature = "pin", issue = "49150")] + pub fn pinned(data: T) -> Pin<Arc<T>> { + unsafe { Pin::new_unchecked(Arc::new(data)) } + } + /// Returns the contained value, if the `Arc` has exactly one strong reference. /// /// Otherwise, an [`Err`][result] is returned with the same `Arc` that was |
