File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -1684,7 +1684,20 @@ methods in such an implementation can only be used as direct calls on the
16841684values of the type that the implementation targets. In such an implementation,
16851685the trait type and ` for ` after ` impl ` are omitted. Such implementations are
16861686limited to nominal types (enums, structs), and the implementation must appear
1687- in the same module or a sub-module as the ` self ` type.
1687+ in the same module or a sub-module as the ` self ` type:
1688+
1689+ ```
1690+ struct Point {x: int, y: int}
1691+
1692+ impl Point {
1693+ fn log(&self) {
1694+ println!("Point is at ({}, {})", self.x, self.y);
1695+ }
1696+ }
1697+
1698+ let my_point = Point {x: 10, y:11};
1699+ my_point.log();
1700+ ```
16881701
16891702When a trait _ is_ specified in an ` impl ` , all methods declared as part of the
16901703trait must be implemented, with matching types and type parameter counts.
You can’t perform that action at this time.
0 commit comments