mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-17 09:23:05 +00:00
Clean up E0120 long explanation
This commit is contained in:
parent
19bd934676
commit
020be74f6b
@ -1,5 +1,7 @@
|
||||
An attempt was made to implement Drop on a trait, which is not allowed: only
|
||||
structs and enums can implement Drop. An example causing this error:
|
||||
The Drop was implemented on a trait, which is not allowed: only structs and
|
||||
enums can implement Drop.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0120
|
||||
trait MyTrait {}
|
||||
@ -10,7 +12,7 @@ impl Drop for MyTrait {
|
||||
```
|
||||
|
||||
A workaround for this problem is to wrap the trait up in a struct, and implement
|
||||
Drop on that. An example is shown below:
|
||||
Drop on that:
|
||||
|
||||
```
|
||||
trait MyTrait {}
|
||||
@ -22,7 +24,7 @@ impl <T: MyTrait> Drop for MyWrapper<T> {
|
||||
|
||||
```
|
||||
|
||||
Alternatively, wrapping trait objects requires something like the following:
|
||||
Alternatively, wrapping trait objects requires something:
|
||||
|
||||
```
|
||||
trait MyTrait {}
|
||||
|
Loading…
Reference in New Issue
Block a user