Rollup merge of #70760 - PonasKovas:docs, r=Dylan-DPC

docs: make the description of Result::map_or more clear

The documentation of [`Result::map_or`](https://doc.rust-lang.org/std/result/enum.Result.html#method.map_or) is very unclear and confusing, probably because it was copied straight from [`Option::map_or`](https://doc.rust-lang.org/std/option/enum.Option.html#method.map_or) and someone forgot to adapt it for Result.
This commit is contained in:
Dylan DPC 2020-04-05 13:13:10 +02:00 committed by GitHub
commit 6f595e8713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -521,14 +521,16 @@ pub fn map<U, F: FnOnce(T) -> U>(self, op: F) -> Result<U, E> {
} }
} }
/// Applies a function to the contained value (if any), /// Applies a function to the contained value (if [`Ok`]),
/// or returns the provided default (if not). /// or returns the provided default (if [`Err`]).
/// ///
/// Arguments passed to `map_or` are eagerly evaluated; if you are passing /// Arguments passed to `map_or` are eagerly evaluated; if you are passing
/// the result of a function call, it is recommended to use [`map_or_else`], /// the result of a function call, it is recommended to use [`map_or_else`],
/// which is lazily evaluated. /// which is lazily evaluated.
/// ///
/// [`map_or_else`]: #method.map_or_else /// [`map_or_else`]: #method.map_or_else
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// ///
/// # Examples /// # Examples
/// ///