Skip to content

Commit 74d61db

Browse files
committed
Restore description of mut on self.
1 parent 0147934 commit 74d61db

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/items/associated-items.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,17 @@ Shorthand | Equivalent
136136

137137
> Note: Lifetimes can be and usually are elided with this shorthand.
138138
139-
Consider the following trait:
139+
If the `self` parameter is prefixed with `mut`, it becomes a mutable variable,
140+
similar to regular parameters using a `mut` [identifier pattern]. For example:
141+
142+
```rust
143+
trait Changer: Sized {
144+
fn change(mut self) {}
145+
fn modify(mut self: Box<Self>) {}
146+
}
147+
```
148+
149+
As an example of methods on a trait, consider the following:
140150

141151
```rust
142152
# type Surface = i32;
@@ -332,6 +342,7 @@ fn main() {
332342
[type aliases]: items/type-aliases.html
333343
[inherent implementations]: items/implementations.html#inherent-implementations
334344
[identifier]: identifiers.html
345+
[identifier pattern]: patterns.html#identifier-patterns
335346
[trait object]: types/trait-object.html
336347
[implementations]: items/implementations.html
337348
[type]: types.html#type-expressions

0 commit comments

Comments
 (0)