diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-07-21 06:52:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-21 06:52:28 +0200 |
| commit | 5ac3684abdf916e54aacf95ec5f1d0f5c98174d3 (patch) | |
| tree | b7b96e2775e10ec8ea6eca91358883f0be906818 | |
| parent | b1d1e99c227b34f2864a1942f0096922a554acd5 (diff) | |
| parent | b1398cac9d529fb818b0fdde44255e99fa63641e (diff) | |
| download | rust-5ac3684abdf916e54aacf95ec5f1d0f5c98174d3.tar.gz rust-5ac3684abdf916e54aacf95ec5f1d0f5c98174d3.zip | |
Rollup merge of #113810 - glandium:allocator-fn, r=Amanieu
Make {Rc,Arc}::allocator associated functions
| -rw-r--r-- | library/alloc/src/rc.rs | 8 | ||||
| -rw-r--r-- | library/alloc/src/sync.rs | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index b3ec830a7d7..bf01b2082ed 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -661,10 +661,14 @@ 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(&self) -> &A { - &self.alloc + pub fn allocator(this: &Self) -> &A { + &this.alloc } /// Constructs a new `Rc` in the provided allocator. /// diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index e00850eb5d8..c2202f2fce5 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -678,10 +678,14 @@ 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(&self) -> &A { - &self.alloc + pub fn allocator(this: &Self) -> &A { + &this.alloc } /// Constructs a new `Arc<T>` in the provided allocator. /// |
