Skip to content

Commit 687a52b

Browse files
committed
Note another surprise.
1 parent e17b9b6 commit 687a52b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/expressions/method-call-expr.md

+25
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,31 @@ There are a few details not considered in this overview:
201201
> }
202202
> ```
203203
204+
The types and number of parameters in the method call expression aren't taken
205+
into account in method resolution. So the following won't compile:
206+
207+
```rust,nocompile
208+
trait NoParameter {
209+
fn method(self);
210+
}
211+
212+
trait OneParameter {
213+
fn method(&self, jj: i32);
214+
}
215+
216+
impl NoParameter for char {
217+
fn method(self) {} // found first and picked, but doesn't work
218+
}
219+
220+
impl OneParameter for char {
221+
fn method(&self, jj: i32) {} // found second, thus ignored
222+
}
223+
224+
fn f() {
225+
'x'.method(123);
226+
}
227+
```
228+
204229
> **Edition differences**: Before the 2021 edition, during the search for visible methods, if the candidate receiver type is an [array type], methods provided by the standard library [`IntoIterator`] trait are ignored.
205230
>
206231
> The edition used for this purpose is determined by the token representing the method name.

0 commit comments

Comments
 (0)