Navigation Menu

Skip to content

Commit

Permalink
reference: clarify impl
Browse files Browse the repository at this point in the history
Another kind of nominal types in Rust are trait objects, so the following is valid

```rust
trait A {

}

impl A {

}
```
  • Loading branch information
matklad committed Oct 26, 2015
1 parent 72ed590 commit 32e4ba8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/doc/reference.md
Expand Up @@ -1520,11 +1520,11 @@ impl Shape for Circle {
```

It is possible to define an implementation without referring to a trait. The
methods in such an implementation can only be used as direct calls on the
values of the type that the implementation targets. In such an implementation,
the trait type and `for` after `impl` are omitted. Such implementations are
limited to nominal types (enums, structs), and the implementation must appear
in the same crate as the `self` type:
methods in such an implementation can only be used as direct calls on the values
of the type that the implementation targets. In such an implementation, the
trait type and `for` after `impl` are omitted. Such implementations are limited
to nominal types (enums, structs, trait objects), and the implementation must
appear in the same crate as the `self` type:

```
struct Point {x: i32, y: i32}
Expand Down

0 comments on commit 32e4ba8

Please sign in to comment.