Skip to content

Commit

Permalink
Move Arc::allocator to T: ?Sized
Browse files Browse the repository at this point in the history
  • Loading branch information
zachs18 committed Feb 19, 2024
1 parent 1920ce9 commit b17fae9
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,16 +683,6 @@ impl<T> Arc<T> {
}

impl<T, A: Allocator> Arc<T, A> {
/// Returns a reference to the underlying allocator.
///
/// Note: this is an associated function, which means that you have
/// to call it as `Arc::allocator(&a)` instead of `a.allocator()`. This
/// is so that there is no conflict with a method on the inner type.
#[inline]
#[unstable(feature = "allocator_api", issue = "32838")]
pub fn allocator(this: &Self) -> &A {
&this.alloc
}
/// Constructs a new `Arc<T>` in the provided allocator.
///
/// # Examples
Expand Down Expand Up @@ -1465,6 +1455,17 @@ impl<T: ?Sized> Arc<T> {
}

impl<T: ?Sized, A: Allocator> Arc<T, A> {
/// Returns a reference to the underlying allocator.
///
/// Note: this is an associated function, which means that you have
/// to call it as `Arc::allocator(&a)` instead of `a.allocator()`. This
/// is so that there is no conflict with a method on the inner type.
#[inline]
#[unstable(feature = "allocator_api", issue = "32838")]
pub fn allocator(this: &Self) -> &A {
&this.alloc
}

/// Consumes the `Arc`, returning the wrapped pointer.
///
/// To avoid a memory leak the pointer must be converted back to an `Arc` using
Expand Down

0 comments on commit b17fae9

Please sign in to comment.