Make {Rc,Arc}::allocator associated functions
This commit is contained in:
parent
da6b55cc5e
commit
b1398cac9d
@ -661,10 +661,14 @@ impl<T> Rc<T> {
|
|||||||
|
|
||||||
impl<T, A: Allocator> Rc<T, A> {
|
impl<T, A: Allocator> Rc<T, A> {
|
||||||
/// Returns a reference to the underlying allocator.
|
/// Returns a reference to the underlying allocator.
|
||||||
|
///
|
||||||
|
/// Note: this is an associated function, which means that you have
|
||||||
|
/// to call it as `Rc::allocator(&r)` instead of `r.allocator()`. This
|
||||||
|
/// is so that there is no conflict with a method on the inner type.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "allocator_api", issue = "32838")]
|
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||||
pub fn allocator(&self) -> &A {
|
pub fn allocator(this: &Self) -> &A {
|
||||||
&self.alloc
|
&this.alloc
|
||||||
}
|
}
|
||||||
/// Constructs a new `Rc` in the provided allocator.
|
/// Constructs a new `Rc` in the provided allocator.
|
||||||
///
|
///
|
||||||
|
@ -678,10 +678,14 @@ impl<T> Arc<T> {
|
|||||||
|
|
||||||
impl<T, A: Allocator> Arc<T, A> {
|
impl<T, A: Allocator> Arc<T, A> {
|
||||||
/// Returns a reference to the underlying allocator.
|
/// 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]
|
#[inline]
|
||||||
#[unstable(feature = "allocator_api", issue = "32838")]
|
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||||
pub fn allocator(&self) -> &A {
|
pub fn allocator(this: &Self) -> &A {
|
||||||
&self.alloc
|
&this.alloc
|
||||||
}
|
}
|
||||||
/// Constructs a new `Arc<T>` in the provided allocator.
|
/// Constructs a new `Arc<T>` in the provided allocator.
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user