Update error code docs even more

This commit is contained in:
Ryan Levick 2021-03-18 17:45:30 +01:00
parent 4f67392c48
commit 2c1429ca5e
2 changed files with 8 additions and 12 deletions

View File

@ -4,7 +4,7 @@ Erroneous code example:
```edition2021,compile_fail,E782
trait Foo {}
fn test(arg: Box<Foo>) {}
fn test(arg: Box<Foo>) {} // error!
```
Trait objects are a way to call methods on types that are not known until
@ -20,7 +20,7 @@ To fix this issue, add `dyn` before the trait name.
```
trait Foo {}
fn test(arg: Box<dyn Foo>) {}
fn test(arg: Box<dyn Foo>) {} // ok!
```
This used to be allowed before edition 2021, but is now an error.

View File

@ -3,11 +3,9 @@ The range pattern `...` is no longer allowed.
Erroneous code example:
```edition2021,compile_fail,E782
fn main() {
match 2u8 {
0...9 => println!("Got a number less than 10"),
_ => println!("Got a number 10 or more")
}
match 2u8 {
0...9 => println!("Got a number less than 10"), // error!
_ => println!("Got a number 10 or more"),
}
```
@ -17,10 +15,8 @@ ranges which are now signified using `..=`.
To make this code compile replace the `...` with `..=`.
```
fn main() {
match 2u8 {
0..=9 => println!("Got a number less than 10"),
_ => println!("Got a number 10 or more")
}
match 2u8 {
0..=9 => println!("Got a number less than 10"), // ok!
_ => println!("Got a number 10 or more"),
}
```