Skip to content

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Dec 31, 2018
1 parent 543a7c7 commit 75a64a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
10 changes: 8 additions & 2 deletions src/items/associated-items.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@ following types:
- [`Box<Self>`]
- [`Rc<Self>`]
- [`Arc<Self>`]
- [`Pin<P>`] where `P` is one of the above types except `Self`.

The `Self` portion of the type may be replaced with the type being
implemented.
As an alternate way of writing the type, the `Self` term may instead be
written with the type being implemented.

```rust
# use std::rc::Rc;
# use std::sync::Arc;
# use std::pin::Pin;
struct Example;
impl Example {
fn by_value(self: Self) {}
Expand All @@ -117,7 +119,9 @@ impl Example {
fn by_box(self: Box<Self>) {}
fn by_rc(self: Rc<Self>) {}
fn by_arc(self: Arc<Self>) {}
fn by_pin(self: Pin<&Self>) {}
fn explicit_type(self: Arc<Example>) {}
fn with_lifetime<'a>(self: &'a Self) {}
}
```

Expand Down Expand Up @@ -321,6 +325,8 @@ fn main() {
[_WhereClause_]: items/generics.html#where-clauses
[`Arc<Self>`]: special-types-and-traits.html#arct
[`Box<Self>`]: special-types-and-traits.html#boxt
[`Deref`]: special-types-and-traits.html#deref-and-derefmut
[`Pin<P>`]: special-types-and-traits.html#pinp
[`Rc<Self>`]: special-types-and-traits.html#rct
[trait]: items/traits.html
[traits]: items/traits.html
Expand Down
5 changes: 5 additions & 0 deletions src/special-types-and-traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ defined types.

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

## `Pin<P>`

[Methods] can take [`Pin<P>`] as a receiver.

## `UnsafeCell<T>`

[`std::cell::UnsafeCell<T>`] is used for [interior mutability]. It ensures that
Expand Down Expand Up @@ -138,6 +142,7 @@ compiler, not by [implementation items].
[`Deref`]: ../std/ops/trait.Deref.html
[`DerefMut`]: ../std/ops/trait.DerefMut.html
[`Drop`]: ../std/ops/trait.Drop.html
[`Pin<P>`]: ../std/pin/struct.Pin.html
[`Rc<Self>`]: ../std/rc/struct.Rc.html
[`RefUnwindSafe`]: ../std/panic/trait.RefUnwindSafe.html
[`Send`]: ../std/marker/trait.Send.html
Expand Down
13 changes: 0 additions & 13 deletions src/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ applies only to the following parameter. For example: `|mut x, y|` and
`fn f(mut x: Box<i32>, y: Box<i32>)` declare one mutable variable `x` and one
immutable variable `y`.

[Methods] that take `self` or one of the supported `Self` types such as
`Box<Self>` can optionally place them in a mutable variable by prefixing them
with `mut` (similar to regular arguments). For example:

```rust
trait Changer: Sized {
fn change(mut self) {}
fn modify(mut self: Box<Self>) {}
}
```

Local variables are not initialized when allocated. Instead, the entire frame
worth of local variables are allocated, on frame-entry, in an uninitialized
state. Subsequent statements within a function may or may not initialize the
Expand All @@ -52,5 +41,3 @@ fn initialization_example() {
// uninit_after_if; // err: use of possibly uninitialized `uninit_after_if`
}
```

[Methods]: items/associated-items.html#methods

0 comments on commit 75a64a6

Please sign in to comment.