Skip to content

Documentation for ? operator and Option does not mention that ? can be used with Option #1679

@arienmalec

Description

@arienmalec

See the discussion in the following Reddit thread:

https://www.reddit.com/r/rust/comments/a4za5j/where_is_for_option_in_the_rfc_process/

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:

  1. 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).
  2. 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."
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions