Skip to content

The ? Operator Can be used in functions that return Option (not just Result) #2173

Closed
@ultrasaurus

Description

@ultrasaurus

? can be used for Option or Result since 1.22 (see blog post)

Documentation in the book says "The ? Operator Can Only Be Used in Functions That Return Result" -- see https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html#recoverable-errors-with-result

the text of this section doesn't match the current capabilities of Rust, or but the displayed error message is correct (maybe the example errors are auto-generated):
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions