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 @@ -1689,7 +1689,20 @@ methods in such an implementation can only be used as direct calls on the
16891689values of the type that the implementation targets. In such an implementation,
16901690the trait type and ` for ` after ` impl ` are omitted. Such implementations are
16911691limited to nominal types (enums, structs), and the implementation must appear
1692- in the same module or a sub-module as the ` self ` type.
1692+ in the same module or a sub-module as the ` self ` type:
1693+
1694+ ```
1695+ struct Point {x: int, y: int}
1696+
1697+ impl Point {
1698+ fn log(&self) {
1699+ println!("Point is at ({}, {})", self.x, self.y);
1700+ }
1701+ }
1702+
1703+ let my_point = Point {x: 10, y:11};
1704+ my_point.log();
1705+ ```
16931706
16941707When a trait _ is_ specified in an ` impl ` , all methods declared as part of the
16951708trait must be implemented, with matching types and type parameter counts.
You can’t perform that action at this time.
0 commit comments