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
{{ message }}
Repository navigation
Documentation for ? operator and Option does not mention that ? can be used with Option #1679
Based on discussion, there is behavior released in Edition 2018 that is not documented in the Edition 2018 book, as well as behavior that is incorrectly documented:
The Try trait and corresponding ? operator work with Option as well as with Result and the ? operator can return None to the surrounding function (if the return from that function is declared as Option<T> as well as Err (if the return is declared as Result).
Section 9.3 incorrectly states : "The ? operator can only be used in functions that have a return type of Result, because it is defined to work in the same way as the match expression we defined in Listing 9-6."
Section 6.3 should either document ? in an Option context or forward reference 9.3 (or a subsequent section) that documents ? in an Option context.
Reacted by Marc-André Lureau, Christoph Schulz, Sebastian Malton, jrop and José Luis Cruz
Activity
arienmalec commentedon Dec 20, 2018
One more point:
Documentation for
?chaining in anOptioncontext should mention thatas_refcan/should be used to avoid?consuming the input.As an example:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d6e33cb4a0b807ccb529cfa5d9c14a53