Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) }
}

Expand Down
10 changes: 8 additions & 2 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,15 +801,21 @@ 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)) }
}

/// Constructs a new `Pin<Arc<T, A>>` in the provided allocator, return an error if allocation
/// 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)?)) }
}

Expand Down
Loading