Add A: 'static bound for Arc/Rc::pin_in

This commit is contained in:
zetanumbers 2024-01-18 14:28:39 +03:00
parent c485ee7147
commit 656a38830b
2 changed files with 12 additions and 3 deletions

View File

@ -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)) }
}

View File

@ -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)?)) }
}