diff options
| author | zetanumbers <dariasukhonina@gmail.com> | 2024-01-18 14:28:39 +0300 |
|---|---|---|
| committer | zetanumbers <dariasukhonina@gmail.com> | 2024-01-18 14:28:39 +0300 |
| commit | 656a38830b5228d5a47222c8f3da2a8346ccab0b (patch) | |
| tree | 32f9b039ea4362fc4feeb1fb8e98eba26b393285 | |
| parent | c485ee71477a29041895c47cc441b364670f3772 (diff) | |
| download | rust-656a38830b5228d5a47222c8f3da2a8346ccab0b.tar.gz rust-656a38830b5228d5a47222c8f3da2a8346ccab0b.zip | |
Add `A: 'static` bound for `Arc/Rc::pin_in`
| -rw-r--r-- | library/alloc/src/rc.rs | 5 | ||||
| -rw-r--r-- | library/alloc/src/sync.rs | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 263b1449de1..a32a0271adf 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -883,7 +883,10 @@ impl<T, A: Allocator> Rc<T, A> { #[cfg(not(no_global_oom_handling))] #[unstable(feature = "allocator_api", issue = "32838")] #[inline] - pub fn pin_in(value: T, alloc: A) -> Pin<Self> { + pub fn pin_in(value: T, alloc: A) -> Pin<Self> + where + A: 'static, + { unsafe { Pin::new_unchecked(Rc::new_in(value, alloc)) } } diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 5273b3cb2da..c389066e6b6 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -801,7 +801,10 @@ impl<T, A: Allocator> Arc<T, A> { #[cfg(not(no_global_oom_handling))] #[unstable(feature = "allocator_api", issue = "32838")] #[inline] - pub fn pin_in(data: T, alloc: A) -> Pin<Arc<T, A>> { + pub fn pin_in(data: T, alloc: A) -> Pin<Arc<T, A>> + where + A: 'static, + { unsafe { Pin::new_unchecked(Arc::new_in(data, alloc)) } } @@ -809,7 +812,10 @@ impl<T, A: Allocator> Arc<T, A> { /// fails. #[inline] #[unstable(feature = "allocator_api", issue = "32838")] - pub fn try_pin_in(data: T, alloc: A) -> Result<Pin<Arc<T, A>>, AllocError> { + pub fn try_pin_in(data: T, alloc: A) -> Result<Pin<Arc<T, A>>, AllocError> + where + A: 'static, + { unsafe { Ok(Pin::new_unchecked(Arc::try_new_in(data, alloc)?)) } } |
