about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHegui Dai <natural_selection_@outlook.com>2025-04-21 10:14:35 +0800
committerHegui Dai <natural_selection_@outlook.com>2025-04-21 10:14:35 +0800
commitf8f23309ca0a77908b7d202bc5780059a86a47d9 (patch)
tree9209d9af4134d248703c3bd8831fd9b8efa15f61
parent13303a5b8e719ef952ab9b060b67e45f74130882 (diff)
downloadrust-f8f23309ca0a77908b7d202bc5780059a86a47d9.tar.gz
rust-f8f23309ca0a77908b7d202bc5780059a86a47d9.zip
Solved suggestions
-rw-r--r--library/core/src/result.rs29
1 files changed, 14 insertions, 15 deletions
diff --git a/library/core/src/result.rs b/library/core/src/result.rs
index 494b3745bc2..1d3da72b05f 100644
--- a/library/core/src/result.rs
+++ b/library/core/src/result.rs
@@ -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>`
@@ -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.
@@ -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
@@ -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`: