mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Add fn allocator method to rc/sync::Weak. Relax Rc<T>/Arc<T>::allocator to allow unsized T.
This commit is contained in:
parent
6a19a87097
commit
a1ad6346d6
@ -661,16 +661,6 @@ impl<T> Rc<T> {
|
||||
}
|
||||
|
||||
impl<T, A: Allocator> Rc<T, A> {
|
||||
/// 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]
|
||||
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||
pub fn allocator(this: &Self) -> &A {
|
||||
&this.alloc
|
||||
}
|
||||
/// Constructs a new `Rc` in the provided allocator.
|
||||
///
|
||||
/// # Examples
|
||||
@ -1333,6 +1323,17 @@ impl<T: ?Sized> Rc<T> {
|
||||
}
|
||||
|
||||
impl<T: ?Sized, A: Allocator> Rc<T, A> {
|
||||
/// 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]
|
||||
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||
pub fn allocator(this: &Self) -> &A {
|
||||
&this.alloc
|
||||
}
|
||||
|
||||
/// Consumes the `Rc`, returning the wrapped pointer.
|
||||
///
|
||||
/// To avoid a memory leak the pointer must be converted back to an `Rc` using
|
||||
@ -2923,6 +2924,13 @@ impl<T: ?Sized> Weak<T> {
|
||||
}
|
||||
|
||||
impl<T: ?Sized, A: Allocator> Weak<T, A> {
|
||||
/// Returns a reference to the underlying allocator.
|
||||
#[inline]
|
||||
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||
pub fn allocator(&self) -> &A {
|
||||
&self.alloc
|
||||
}
|
||||
|
||||
/// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
|
||||
///
|
||||
/// The pointer is valid only if there are some strong references. The pointer may be dangling,
|
||||
|
@ -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
|
||||
@ -1473,6 +1463,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
|
||||
@ -2661,6 +2662,13 @@ impl<T: ?Sized> Weak<T> {
|
||||
}
|
||||
|
||||
impl<T: ?Sized, A: Allocator> Weak<T, A> {
|
||||
/// Returns a reference to the underlying allocator.
|
||||
#[inline]
|
||||
#[unstable(feature = "allocator_api", issue = "32838")]
|
||||
pub fn allocator(&self) -> &A {
|
||||
&self.alloc
|
||||
}
|
||||
|
||||
/// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
|
||||
///
|
||||
/// The pointer is valid only if there are some strong references. The pointer may be dangling,
|
||||
|
Loading…
Reference in New Issue
Block a user