Skip to content

Commit

Permalink
Auto merge of rust-lang#84609 - lefth:master, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Reorder the parameter descriptions of map_or and map_or_else

They were described backwards, probably leading users to write arguments in the wrong order. Bug: rust-lang#84608
  • Loading branch information
bors committed Apr 27, 2021
2 parents dc8cb63 + 6c22b39 commit 1919b3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ impl<T> Option<T> {
}
}

/// Applies a function to the contained value (if any),
/// or returns the provided default (if not).
/// Returns the provided default result (if none),
/// or applies a function to the contained value (if any).
///
/// 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`],
Expand All @@ -516,8 +516,8 @@ impl<T> Option<T> {
}
}

/// Applies a function to the contained value (if any),
/// or computes a default (if not).
/// Computes a default function result (if none), or
/// applies a different function to the contained value (if any).
///
/// # Examples
///
Expand Down
10 changes: 5 additions & 5 deletions library/core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ impl<T, E> Result<T, E> {
}
}

/// Applies a function to the contained value (if [`Ok`]),
/// or returns the provided default (if [`Err`]).
/// Returns the provided default (if [`Err`]), or
/// applies a function to the contained value (if [`Ok`]),
///
/// 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`],
Expand All @@ -533,9 +533,9 @@ impl<T, E> Result<T, E> {
}
}

/// Maps a `Result<T, E>` to `U` by applying a function to a
/// contained [`Ok`] value, or a fallback function to a
/// contained [`Err`] value.
/// Maps a `Result<T, E>` to `U` by applying a fallback function to a
/// contained [`Err`] value, or a default function to a
/// contained [`Ok`] value.
///
/// This function can be used to unpack a successful result
/// while handling an error.
Expand Down

0 comments on commit 1919b3f

Please sign in to comment.