Add `dyn
` keyword
This commit is contained in:
parent
d491662340
commit
a89cddb2be
1 changed files with 2 additions and 2 deletions
|
@ -3,7 +3,7 @@ A captured variable in a closure may not live long enough.
|
|||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0373
|
||||
fn foo() -> Box<Fn(u32) -> u32> {
|
||||
fn foo() -> Box<dyn Fn(u32) -> u32> {
|
||||
let x = 0u32;
|
||||
Box::new(|y| x + y)
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ This approach moves (or copies, where possible) data into the closure, rather
|
|||
than taking references to it. For example:
|
||||
|
||||
```
|
||||
fn foo() -> Box<Fn(u32) -> u32> {
|
||||
fn foo() -> Box<dyn Fn(u32) -> u32> {
|
||||
let x = 0u32;
|
||||
Box::new(move |y| x + y)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue