Solved suggestions

This commit is contained in:
Hegui Dai
2025-04-21 10:14:35 +08:00
parent 13303a5b8e
commit f8f23309ca
+14 -15
View File
@@ -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`: