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

This commit is contained in:
Ponas 2020-04-04 14:18:02 +03:00
parent 1b521f5773
commit b4f416d837

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),
/// or returns the provided default (if not).
/// Applies a function to the contained value (if [`Ok`]),
/// or returns the provided default (if [`Err`]).
///
/// 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`],
/// which is lazily evaluated.
///
/// [`map_or_else`]: #method.map_or_else
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
///
/// # Examples
///