Skip to content

Commit fc126df

Browse files
Update the index.html of Option to make the summary more comprehensive
1 parent 7d49ae9 commit fc126df

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

library/core/src/option.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,17 @@
159159
//!
160160
//! ## Querying the variant
161161
//!
162-
//! The [`is_some`] and [`is_none`] methods return [`true`] if the [`Option`]
163-
//! is [`Some`] or [`None`], respectively.
162+
//! The [`is_some`] and [`is_none`] methods take a borrow of the [`Option`]
163+
//! and return [`true`] if the [`Option`] is [`Some`] or [`None`], respectively.
164+
//!
165+
//! The [`is_some_and`] and [`is_none_or`] methods take ownership of the [`Option`]
166+
//! and apply the provided function to make a decision.
167+
//! The methods return the same boolean value as the function returns.
164168
//!
165169
//! [`is_none`]: Option::is_none
166170
//! [`is_some`]: Option::is_some
171+
//! [`is_some_and`]: Option::is_some_and
172+
//! [`is_none_or`]: Option::is_none_or
167173
//!
168174
//! ## Adapters for working with references
169175
//!
@@ -177,6 +183,10 @@
177183
//! <code>[Option]<[Pin]<[&]T>></code>
178184
//! * [`as_pin_mut`] converts from <code>[Pin]<[&mut] [Option]\<T>></code> to
179185
//! <code>[Option]<[Pin]<[&mut] T>></code>
186+
//! * [`as_slice`] returns a slice of the contained value, if any.
187+
//! If this is [`None`], an empty slice is returned.
188+
//! * [`as_mut_slice`] returns a mutable slice of the contained value, if any.
189+
//! If this is [`None`], an empty slice is returned.
180190
//!
181191
//! [&]: reference "shared reference"
182192
//! [&mut]: reference "mutable reference"
@@ -187,6 +197,8 @@
187197
//! [`as_pin_mut`]: Option::as_pin_mut
188198
//! [`as_pin_ref`]: Option::as_pin_ref
189199
//! [`as_ref`]: Option::as_ref
200+
//! [`as_slice`]: Option::as_slice
201+
//! [`as_mut_slice`]: Option::as_mut_slice
190202
//!
191203
//! ## Extracting the contained value
192204
//!
@@ -200,12 +212,16 @@
200212
//! (which must implement the [`Default`] trait)
201213
//! * [`unwrap_or_else`] returns the result of evaluating the provided
202214
//! function
215+
//! * [`unwrap_unchecked`] returns the contained value, without checking
216+
//! calling this method on None is *[undefined behavior]*
203217
//!
204218
//! [`expect`]: Option::expect
205219
//! [`unwrap`]: Option::unwrap
206220
//! [`unwrap_or`]: Option::unwrap_or
207221
//! [`unwrap_or_default`]: Option::unwrap_or_default
208222
//! [`unwrap_or_else`]: Option::unwrap_or_else
223+
//! [`unwrap_unchecked`]: Option::unwrap_unchecked
224+
//! [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
209225
//!
210226
//! ## Transforming contained values
211227
//!
@@ -232,13 +248,16 @@
232248
//! if the function returns `true`; otherwise, returns [`None`]
233249
//! * [`flatten`] removes one level of nesting from an
234250
//! [`Option<Option<T>>`]
251+
//! * [`insert`] calls the provided function with a reference to
252+
//! the contained value if [`Some`]
235253
//! * [`map`] transforms [`Option<T>`] to [`Option<U>`] by applying the
236254
//! provided function to the contained value of [`Some`] and leaving
237255
//! [`None`] values unchanged
238256
//!
239257
//! [`Some(t)`]: Some
240258
//! [`filter`]: Option::filter
241259
//! [`flatten`]: Option::flatten
260+
//! [`insert`]: Option::insert
242261
//! [`map`]: Option::map
243262
//!
244263
//! These methods transform [`Option<T>`] to a value of a possibly

0 commit comments

Comments
 (0)