Closed
Description
Location
https://doc.rust-lang.org/std/option/enum.Option.html#method.unwrap_or_default
Summary
It appears that the example was wrongly adapted from Result::unwrap_or_default, however the example does not work here because parse will never return None, its returns a Result. It appears that ideally a more fitting example should be written.
Activity
ghost commentedon Aug 2, 2022
The documentation seems alright? Yes,
parse
returns aResult
-- The example is callingResult::ok
to convertResult<T>
toOption<T>
and then usingOption::unwrap_or_default
.ArtifyCZ commentedon Aug 5, 2022
I think there could be for people like this (no offensive) type annotations.
GuillaumeGomez commentedon Sep 25, 2022
The example could be simplified indeed.
ghost commentedon Sep 25, 2022
@rustbot claim
Rollup merge of rust-lang#102259 - gimbles:patch-1, r=joshtriplett
Rollup merge of rust-lang#102283 - GuillaumeGomez:option-code-example…
Rollup merge of rust-lang#102283 - GuillaumeGomez:option-code-example…
Auto merge of rust-lang#102283 - GuillaumeGomez:option-code-example-u…