We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b15e71a commit 423de1cCopy full SHA for 423de1c
compiler/rustc_error_codes/src/error_codes/E0642.md
@@ -1,4 +1,8 @@
1
-Trait methods currently cannot take patterns as arguments.
+Trait methods cannot take patterns as arguments.
2
+
3
+Traits cannot control the way in which implementations take arguments, only the
4
+types of those arguments. A pattern here has no effect, because the
5
+implementation can bind its arguments however it would like.
6
7
Erroneous code example:
8
@@ -16,3 +20,9 @@ trait Foo {
16
20
fn foo(x_and_y: (i32, i32)); // ok!
17
21
}
18
22
```
23
24
+And you can use patterns in its implementations:
25
26
+impl Foo for Bar {
27
+ fn foo((x, y): (i32, i32)) { /* ... */ } // ok!
28
+}
0 commit comments