Skip to content

Commit

Permalink
Review comment regarding Rc/etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
adetaylor committed Jan 28, 2025
1 parent cea25a8 commit 0ecbbf8
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions src/special-types-and-traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,12 @@ r[lang-types.box.deref]
* The [dereference operator] for `Box<T>` produces a place which can be moved
from. This means that the `*` operator and the destructor of `Box<T>` are
built-in to the language.

r[lang-types.box.receiver]
* [Methods] can take `Box<Self>` as a receiver.

r[lang-types.box.fundamental]
* A trait may be implemented for `Box<T>` in the same crate as `T`, which the
[orphan rules] prevent for other generic types.

<!-- Editor Note: This is nowhere close to an exhaustive list -->

r[lang-types.rc]
## `Rc<T>`

r[lang-types.rc.receiver]
[Methods] can take [`Rc<Self>`] as a receiver.

r[lang-types.arc]
## `Arc<T>`

r[lang-types.arc.receiver]
[Methods] can take [`Arc<Self>`] as a receiver.

r[lang-types.pin]
## `Pin<P>`

r[lang-types.pin.receiver]
[Methods] can take [`Pin<P>`] as a receiver.

r[lang-types.unsafe-cell]
## `UnsafeCell<T>`

Expand Down Expand Up @@ -83,6 +61,9 @@ used as a method receiver; that is, the type of a `self` parameter for a
method. There is a blanket implementation of `Receiver` for all `T: Deref`,
so it's rare to implement `Receiver` directly: you'd only normally do this
for smart pointer types which for some reason can't implement `Deref`.
Built-in types which implement `Receiver` (via `Deref`) and are commonly
used as method receivers include `Rc<T>`, `Arc<T>`, `Box<T>`, and `Pin<P>`
where `P: Deref`.

r[lang-types.drop]
## `Drop`
Expand Down

0 comments on commit 0ecbbf8

Please sign in to comment.