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
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
You can’t perform that action at this time.
0 commit comments