Skip to content

Commit 11dec77

Browse files
committed
Review comment regarding Rc/etc.
1 parent 27ab965 commit 11dec77

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/special-types-and-traits.md

+3-13
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,9 @@ defined types.
1212
* The [dereference operator] for `Box<T>` produces a place which can be moved
1313
from. This means that the `*` operator and the destructor of `Box<T>` are
1414
built-in to the language.
15-
* [Methods] can take `Box<Self>` as a receiver.
1615
* A trait may be implemented for `Box<T>` in the same crate as `T`, which the
1716
[orphan rules] prevent for other generic types.
1817

19-
## `Rc<T>`
20-
21-
[Methods] can take [`Rc<Self>`] as a receiver.
22-
23-
## `Arc<T>`
24-
25-
[Methods] can take [`Arc<Self>`] as a receiver.
26-
27-
## `Pin<P>`
28-
29-
[Methods] can take [`Pin<P>`] as a receiver.
30-
3118
## `UnsafeCell<T>`
3219

3320
[`std::cell::UnsafeCell<T>`] is used for [interior mutability]. It ensures that
@@ -58,6 +45,9 @@ used as a method receiver; that is, the type of a `self` parameter for a
5845
method. There is a blanket implementation of `Receiver` for all `T: Deref`,
5946
so it's rare to implement `Receiver` directly: you'd only normally do this
6047
for smart pointer types which for some reason can't implement `Deref`.
48+
Built-in types which implement `Receiver` (via `Deref`) and are commonly
49+
used as method receivers include `Rc<T>`, `Arc<T>`, `Box<T>`, and `Pin<P>`
50+
where `P: Deref`.
6151

6252
## `Drop`
6353

0 commit comments

Comments
 (0)