Solved suggestions

This commit is contained in:
Hegui Dai 2025-04-21 09:54:11 +08:00
parent 159ae8fcee
commit ea0b6cba06

View file

@ -159,25 +159,18 @@
//!
//! ## Querying the variant
//!
//! The [`is_some`] and [`is_none`] methods take a borrow of the [`Option`]
//! The [`is_some`] and [`is_none`] methods borrow of the [`Option`]
//! and return [`true`] if the [`Option`] is [`Some`] or [`None`], respectively.
//!
//! The [`is_some_and`] and [`is_none_or`] methods take ownership of the [`Option`]
//! and apply the provided function to make a decision.
//! The methods return the same boolean value as the function returns.
//! The [`is_some_and`] and [`is_none_or`] methods apply the provided function
//! to the contents of the [`Option`] to produce a boolean value.
//! If this is [`None`] then a default result is returned instead without executing the function.
//!
//! [`is_none`]: Option::is_none
//! [`is_some`]: Option::is_some
//! [`is_some_and`]: Option::is_some_and
//! [`is_none_or`]: Option::is_none_or
//!
//! ## Inspecting the variant
//!
//! The [`inspect`] method takes ownership of the [`Option`]
//! and applies the provided function to the contained value by reference if [`Some`]
//!
//! [`inspect`]: Option::inspect
//!
//! ## Adapters for working with references
//!
//! * [`as_ref`] converts from <code>[&][][Option]\<T></code> to <code>[Option]<[&]T></code>
@ -190,9 +183,9 @@
//! <code>[Option]<[Pin]<[&]T>></code>
//! * [`as_pin_mut`] converts from <code>[Pin]<[&mut] [Option]\<T>></code> to
//! <code>[Option]<[Pin]<[&mut] T>></code>
//! * [`as_slice`] returns a slice of the contained value, if any.
//! * [`as_slice`] returns a one-element slice of the contained value, if any.
//! If this is [`None`], an empty slice is returned.
//! * [`as_mut_slice`] returns a mutable slice of the contained value, if any.
//! * [`as_mut_slice`] returns a mutable one-element slice of the contained value, if any.
//! If this is [`None`], an empty slice is returned.
//!
//! [&]: reference "shared reference"
@ -219,8 +212,7 @@
//! (which must implement the [`Default`] trait)
//! * [`unwrap_or_else`] returns the result of evaluating the provided
//! function
//! * [`unwrap_unchecked`] returns the contained value, without checking
//! calling this method on None is *[undefined behavior]*
//! * [`unwrap_unchecked`] produces *[undefined behavior]*
//!
//! [`expect`]: Option::expect
//! [`unwrap`]: Option::unwrap
@ -253,8 +245,9 @@
//! * [`filter`] calls the provided predicate function on the contained
//! value `t` if the [`Option`] is [`Some(t)`], and returns [`Some(t)`]
//! if the function returns `true`; otherwise, returns [`None`]
//! * [`flatten`] removes one level of nesting from an
//! [`Option<Option<T>>`]
//! * [`flatten`] removes one level of nesting from an [`Option<Option<T>>`]
//! * [`inspect`] method takes ownership of the [`Option`] and applies
//! the provided function to the contained value by reference if [`Some`]
//! * [`map`] transforms [`Option<T>`] to [`Option<U>`] by applying the
//! provided function to the contained value of [`Some`] and leaving
//! [`None`] values unchanged
@ -262,6 +255,7 @@
//! [`Some(t)`]: Some
//! [`filter`]: Option::filter
//! [`flatten`]: Option::flatten
//! [`inspect`]: Option::inspect
//! [`map`]: Option::map
//!
//! These methods transform [`Option<T>`] to a value of a possibly