Rollup merge of #124980 - zachs18:rc-allocator, r=Amanieu · rust-lang/rust@65ea92d

@@ -665,16 +665,6 @@ impl<T> Rc<T> {

665665

}

666666667667

impl<T, A: Allocator> Rc<T, A> {

668-

/// Returns a reference to the underlying allocator.

669-

///

670-

/// Note: this is an associated function, which means that you have

671-

/// to call it as `Rc::allocator(&r)` instead of `r.allocator()`. This

672-

/// is so that there is no conflict with a method on the inner type.

673-

#[inline]

674-

#[unstable(feature = "allocator_api", issue = "32838")]

675-

pub fn allocator(this: &Self) -> &A {

676-

&this.alloc

677-

}

678668

/// Constructs a new `Rc` in the provided allocator.

679669

///

680670

/// # Examples

@@ -1331,6 +1321,17 @@ impl<T: ?Sized> Rc<T> {

13311321

}

1332132213331323

impl<T: ?Sized, A: Allocator> Rc<T, A> {

1324+

/// Returns a reference to the underlying allocator.

1325+

///

1326+

/// Note: this is an associated function, which means that you have

1327+

/// to call it as `Rc::allocator(&r)` instead of `r.allocator()`. This

1328+

/// is so that there is no conflict with a method on the inner type.

1329+

#[inline]

1330+

#[unstable(feature = "allocator_api", issue = "32838")]

1331+

pub fn allocator(this: &Self) -> &A {

1332+

&this.alloc

1333+

}

1334+13341335

/// Consumes the `Rc`, returning the wrapped pointer.

13351336

///

13361337

/// To avoid a memory leak the pointer must be converted back to an `Rc` using

@@ -2994,6 +2995,13 @@ impl<T: ?Sized> Weak<T> {

29942995

}

2995299629962997

impl<T: ?Sized, A: Allocator> Weak<T, A> {

2998+

/// Returns a reference to the underlying allocator.

2999+

#[inline]

3000+

#[unstable(feature = "allocator_api", issue = "32838")]

3001+

pub fn allocator(&self) -> &A {

3002+

&self.alloc

3003+

}

3004+29973005

/// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.

29983006

///

29993007

/// The pointer is valid only if there are some strong references. The pointer may be dangling,