Skip to content

Update the index of Result to make the summary more comprehensive #138968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 25, 2025
Merged
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
29 changes: 14 additions & 15 deletions library/core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,27 +256,18 @@
//!
//! ## Querying the variant
//!
//! The [`is_ok`] and [`is_err`] methods take the borrow of the [`Result`]
//! The [`is_ok`] and [`is_err`] methods borrow of the [`Result`]
//! and return [`true`] if the [`Result`] is [`Ok`] or [`Err`], respectively.
//!
//! The [`is_ok_and`] and [`is_err_and`] methods take ownership of the [`Result`]
//! and apply the provided function to make a decision.
//! The methods return the same boolean value as the function returns.
//! The [`is_ok_and`] and [`is_err_and`] methods apply the provided function
//! to the contents of the [`Result`] to produce a boolean value. If this is [`Err`]
//! then a default result is returned instead without executing the function.
//!
//! [`is_err`]: Result::is_err
//! [`is_ok`]: Result::is_ok
//! [`is_ok_and`]: Result::is_ok_and
//! [`is_err_and`]: Result::is_err_and
//!
//! ## Inspecting the variant
//!
//! The [`inspect`] and [`inspect_err`] methods take ownership of the [`Result`]
//! and apply the provided function to the contained value by reference if [`Ok`]
//! or [`Err`], respectively. And then, the [`Result`] is returned.
//!
//! [`inspect`]: Result::inspect
//! [`inspect_err`]: Result::inspect_err
//!
//! ## Adapters for working with references
//!
//! * [`as_ref`] converts from `&Result<T, E>` to `Result<&T, &E>`
Expand All @@ -302,7 +293,7 @@
//! (which must implement the [`Default`] trait)
//! * [`unwrap_or_else`] returns the result of evaluating the provided
//! function
//! * [`unwrap_unchecked`] is *[undefined behavior]*
//! * [`unwrap_unchecked`] produces *[undefined behavior]*
//!
//! The panicking methods [`expect`] and [`unwrap`] require `E` to
//! implement the [`Debug`] trait.
Expand All @@ -322,7 +313,7 @@
//!
//! * [`expect_err`] panics with a provided custom message
//! * [`unwrap_err`] panics with a generic message
//! * [`unwrap_err_unchecked`] is *[undefined behavior]*
//! * [`unwrap_err_unchecked`] produces *[undefined behavior]*
//!
//! [`Debug`]: crate::fmt::Debug
//! [`expect_err`]: Result::expect_err
Expand Down Expand Up @@ -356,16 +347,24 @@
//! * [`map`] transforms [`Result<T, E>`] into [`Result<U, E>`] by applying
//! the provided function to the contained value of [`Ok`] and leaving
//! [`Err`] values unchanged
//! * [`inspect`] takes ownership of the [`Result`] and applies the
//! provided function to the contained value by reference,
//! and then the [`Result`] is returned
//!
//! [`map`]: Result::map
//! [`inspect`]: Result::inspect
//!
//! This method transforms the contained value of the [`Err`] variant:
//!
//! * [`map_err`] transforms [`Result<T, E>`] into [`Result<T, F>`] by
//! applying the provided function to the contained value of [`Err`] and
//! leaving [`Ok`] values unchanged
//! * [`inspect_err`] takes ownership of the [`Result`] and applies the
//! provided function to the contained value of [`Err`] by reference,
//! and then the [`Result`] is returned
//!
//! [`map_err`]: Result::map_err
//! [`inspect_err`]: Result::inspect_err
//!
//! These methods transform a [`Result<T, E>`] into a value of a possibly
//! different type `U`:
Expand Down
Loading