rust
rust copied to clipboard
Inaccuracy in the documentation for Option::unwrap_or_default
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.
The documentation seems alright? Yes, parse
returns a Result
-- The example is calling Result::ok
to convert Result<T>
to Option<T>
and then using Option::unwrap_or_default
.
I think there could be for people like this (no offensive) type annotations.
The example could be simplified indeed.
@rustbot claim