You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a newcomer to Rust I was extremely confused for a while with this, because the book taught me to use Box<dyn Trait> but I saw everyone doing the impl Trait syntax. I was confused at first because I didn't even realize both syntaxes were trying to do the same thing and I kinda assumed the impl syntax was a different feature of the language I didn't know about.
The existing text here has a long historical record; it predates `impl`
or `dyn` existing at all, much less the version we landed on in Rust
2018. Update it to suggest defaulting to `impl Fn`, with trait objects
`Box<dyn Fn>` the fallback.
Fixes#1514Fixes#3272
Hello,
I searched the issues but did not find an existing relevant one.
The only provided solution for returning closure in this section is using Box:
https://doc.rust-lang.org/book/2018-edition/ch19-05-advanced-functions-and-closures.html#returning-closures
This now compiles on Rust stable, so it seem like it would be a good alternative to put for this advance topic section:
https://play.rust-lang.org/?gist=ce094b09ea045b0e40a69d3fc3158500&version=stable&mode=debug&edition=2015
Thanks,
Jean-Philippe.
The text was updated successfully, but these errors were encountered: