mirror of https://github.com/rust-lang/reference
paths.md: document standalone `self` in a method body
This commit is contained in:
parent
cd8193e972
commit
e8ddd3cd6b
|
@ -202,11 +202,20 @@ mod b {
|
|||
`self` resolves the path relative to the current module. `self` can only be used as the
|
||||
first segment, without a preceding `::`.
|
||||
|
||||
In a method body, a path which consists of a single `self` segment resolves to the method's self parameter.
|
||||
|
||||
|
||||
```rust
|
||||
fn foo() {}
|
||||
fn bar() {
|
||||
self::foo();
|
||||
}
|
||||
struct S(bool);
|
||||
impl S {
|
||||
fn baz(self) {
|
||||
self.0;
|
||||
}
|
||||
}
|
||||
# fn main() {}
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue