Skip to content

Commit 75a64a6

Browse files
committed
Address review comments.
1 parent 543a7c7 commit 75a64a6

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

src/items/associated-items.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,15 @@ following types:
102102
- [`Box<Self>`]
103103
- [`Rc<Self>`]
104104
- [`Arc<Self>`]
105+
- [`Pin<P>`] where `P` is one of the above types except `Self`.
105106

106-
The `Self` portion of the type may be replaced with the type being
107-
implemented.
107+
As an alternate way of writing the type, the `Self` term may instead be
108+
written with the type being implemented.
108109

109110
```rust
110111
# use std::rc::Rc;
111112
# use std::sync::Arc;
113+
# use std::pin::Pin;
112114
struct Example;
113115
impl Example {
114116
fn by_value(self: Self) {}
@@ -117,7 +119,9 @@ impl Example {
117119
fn by_box(self: Box<Self>) {}
118120
fn by_rc(self: Rc<Self>) {}
119121
fn by_arc(self: Arc<Self>) {}
122+
fn by_pin(self: Pin<&Self>) {}
120123
fn explicit_type(self: Arc<Example>) {}
124+
fn with_lifetime<'a>(self: &'a Self) {}
121125
}
122126
```
123127

@@ -321,6 +325,8 @@ fn main() {
321325
[_WhereClause_]: items/generics.html#where-clauses
322326
[`Arc<Self>`]: special-types-and-traits.html#arct
323327
[`Box<Self>`]: special-types-and-traits.html#boxt
328+
[`Deref`]: special-types-and-traits.html#deref-and-derefmut
329+
[`Pin<P>`]: special-types-and-traits.html#pinp
324330
[`Rc<Self>`]: special-types-and-traits.html#rct
325331
[trait]: items/traits.html
326332
[traits]: items/traits.html

src/special-types-and-traits.md

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ defined types.
2424

2525
[Methods] can take [`Arc<Self>`] as a receiver.
2626

27+
## `Pin<P>`
28+
29+
[Methods] can take [`Pin<P>`] as a receiver.
30+
2731
## `UnsafeCell<T>`
2832

2933
[`std::cell::UnsafeCell<T>`] is used for [interior mutability]. It ensures that
@@ -138,6 +142,7 @@ compiler, not by [implementation items].
138142
[`Deref`]: ../std/ops/trait.Deref.html
139143
[`DerefMut`]: ../std/ops/trait.DerefMut.html
140144
[`Drop`]: ../std/ops/trait.Drop.html
145+
[`Pin<P>`]: ../std/pin/struct.Pin.html
141146
[`Rc<Self>`]: ../std/rc/struct.Rc.html
142147
[`RefUnwindSafe`]: ../std/panic/trait.RefUnwindSafe.html
143148
[`Send`]: ../std/marker/trait.Send.html

src/variables.md

-13
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,6 @@ applies only to the following parameter. For example: `|mut x, y|` and
1515
`fn f(mut x: Box<i32>, y: Box<i32>)` declare one mutable variable `x` and one
1616
immutable variable `y`.
1717

18-
[Methods] that take `self` or one of the supported `Self` types such as
19-
`Box<Self>` can optionally place them in a mutable variable by prefixing them
20-
with `mut` (similar to regular arguments). For example:
21-
22-
```rust
23-
trait Changer: Sized {
24-
fn change(mut self) {}
25-
fn modify(mut self: Box<Self>) {}
26-
}
27-
```
28-
2918
Local variables are not initialized when allocated. Instead, the entire frame
3019
worth of local variables are allocated, on frame-entry, in an uninitialized
3120
state. Subsequent statements within a function may or may not initialize the
@@ -52,5 +41,3 @@ fn initialization_example() {
5241
// uninit_after_if; // err: use of possibly uninitialized `uninit_after_if`
5342
}
5443
```
55-
56-
[Methods]: items/associated-items.html#methods

0 commit comments

Comments
 (0)