Add fn allocator method to rc/sync::Weak. Relax Rc/Arc::allocat… · rust-lang/rust@a1ad634 (original) (raw)
`@@ -661,16 +661,6 @@ impl Rc {
`
661
661
`}
`
662
662
``
663
663
`impl<T, A: Allocator> Rc<T, A> {
`
664
``
`-
/// Returns a reference to the underlying allocator.
`
665
``
`-
///
`
666
``
`-
/// Note: this is an associated function, which means that you have
`
667
``
`` -
/// to call it as Rc::allocator(&r)
instead of r.allocator()
. This
``
668
``
`-
/// is so that there is no conflict with a method on the inner type.
`
669
``
`-
#[inline]
`
670
``
`-
#[unstable(feature = "allocator_api", issue = "32838")]
`
671
``
`-
pub fn allocator(this: &Self) -> &A {
`
672
``
`-
&this.alloc
`
673
``
`-
}
`
674
664
`` /// Constructs a new Rc
in the provided allocator.
``
675
665
`///
`
676
666
`/// # Examples
`
`@@ -1333,6 +1323,17 @@ impl<T: ?Sized> Rc {
`
1333
1323
`}
`
1334
1324
``
1335
1325
`impl<T: ?Sized, A: Allocator> Rc<T, A> {
`
``
1326
`+
/// Returns a reference to the underlying allocator.
`
``
1327
`+
///
`
``
1328
`+
/// Note: this is an associated function, which means that you have
`
``
1329
`` +
/// to call it as Rc::allocator(&r)
instead of r.allocator()
. This
``
``
1330
`+
/// is so that there is no conflict with a method on the inner type.
`
``
1331
`+
#[inline]
`
``
1332
`+
#[unstable(feature = "allocator_api", issue = "32838")]
`
``
1333
`+
pub fn allocator(this: &Self) -> &A {
`
``
1334
`+
&this.alloc
`
``
1335
`+
}
`
``
1336
+
1336
1337
`` /// Consumes the Rc
, returning the wrapped pointer.
``
1337
1338
`///
`
1338
1339
`` /// To avoid a memory leak the pointer must be converted back to an Rc
using
``
`@@ -2923,6 +2924,13 @@ impl<T: ?Sized> Weak {
`
2923
2924
`}
`
2924
2925
``
2925
2926
`impl<T: ?Sized, A: Allocator> Weak<T, A> {
`
``
2927
`+
/// Returns a reference to the underlying allocator.
`
``
2928
`+
#[inline]
`
``
2929
`+
#[unstable(feature = "allocator_api", issue = "32838")]
`
``
2930
`+
pub fn allocator(&self) -> &A {
`
``
2931
`+
&self.alloc
`
``
2932
`+
}
`
``
2933
+
2926
2934
`` /// Returns a raw pointer to the object T
pointed to by this Weak<T>
.
``
2927
2935
`///
`
2928
2936
`/// The pointer is valid only if there are some strong references. The pointer may be dangling,
`