File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,17 @@ Shorthand | Equivalent
136
136
137
137
> Note: Lifetimes can be and usually are elided with this shorthand.
138
138
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:
140
150
141
151
``` rust
142
152
# type Surface = i32 ;
@@ -332,6 +342,7 @@ fn main() {
332
342
[ type aliases ] : items/type-aliases.html
333
343
[ inherent implementations ] : items/implementations.html#inherent-implementations
334
344
[ identifier ] : identifiers.html
345
+ [ identifier pattern ] : patterns.html#identifier-patterns
335
346
[ trait object ] : types/trait-object.html
336
347
[ implementations ] : items/implementations.html
337
348
[ type ] : types.html#type-expressions
You can’t perform that action at this time.
0 commit comments