Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ impl<T> Option<T> {

/// Returns the contained value or a default.
///
/// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing
/// the result of a function call, it is recommended to use `unwrap_or_else`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you link to the unwrap_or_else method? i.e.

/// ... it is recommended to use [`unwrap_or_else`],
///
/// ...
///
/// [`unwrap_or_else`]: #method.unwrap_or_else

Similar for the other additions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure - will do

/// which is lazily evaluated.
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -451,6 +455,10 @@ impl<T> Option<T> {
/// Transforms the `Option<T>` into a [`Result<T, E>`], mapping [`Some(v)`] to
/// [`Ok(v)`] and [`None`] to [`Err(err)`].
///
/// Arguments passed to `ok_or` are eagerly evaluated; if you are passing the
/// result of a function call, it is recommended to use `ok_or_else`, which is
/// lazily evaluated.
///
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
/// [`Ok(v)`]: ../../std/result/enum.Result.html#variant.Ok
/// [`Err(err)`]: ../../std/result/enum.Result.html#variant.Err
Expand Down Expand Up @@ -609,6 +617,10 @@ impl<T> Option<T> {

/// Returns the option if it contains a value, otherwise returns `optb`.
///
/// Arguments passed to `or` are eagerly evaluated; if you are passing the
/// result of a function call, it is recommended to use `or_else`, which is
/// lazily evaluated.
///
/// # Examples
///
/// ```
Expand Down
8 changes: 8 additions & 0 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,10 @@ impl<T, E> Result<T, E> {

/// Returns `res` if the result is [`Err`], otherwise returns the [`Ok`] value of `self`.
///
/// Arguments passed to `or` are eagerly evaluated; if you are passing the
/// result of a function call, it is recommended to use `or_else`, which is
/// lazily evaluated.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
///
Expand Down Expand Up @@ -690,6 +694,10 @@ impl<T, E> Result<T, E> {
/// Unwraps a result, yielding the content of an [`Ok`].
/// Else, it returns `optb`.
///
/// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a trailing whitespace on this line, causing the CI to reject this PR. Other places affected:

[00:04:39] tidy error: /checkout/src/libcore/result.rs:697: trailing whitespace
[00:04:39] tidy error: /checkout/src/libcore/result.rs:698: trailing whitespace
[00:04:39] tidy error: /checkout/src/libcore/result.rs:699: trailing whitespace
[00:04:39] tidy error: /checkout/src/libcore/option.rs:341: trailing whitespace
[00:04:39] tidy error: /checkout/src/libcore/option.rs:342: trailing whitespace
[00:04:39] tidy error: /checkout/src/libcore/option.rs:343: trailing whitespace
[00:04:41] some tidy checks failed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

/// the result of a function call, it is recommended to use `unwrap_or_else`,
/// which is lazily evaluated.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
///
Expand Down