Skip to content

Commit 13303a5

Browse files
Update the index of Result to make the summary more comprehensive
1 parent 7d49ae9 commit 13303a5

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

library/core/src/result.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,26 @@
256256
//!
257257
//! ## Querying the variant
258258
//!
259-
//! The [`is_ok`] and [`is_err`] methods return [`true`] if the [`Result`]
260-
//! is [`Ok`] or [`Err`], respectively.
259+
//! The [`is_ok`] and [`is_err`] methods take the borrow of the [`Result`]
260+
//! and return [`true`] if the [`Result`] is [`Ok`] or [`Err`], respectively.
261+
//!
262+
//! The [`is_ok_and`] and [`is_err_and`] methods take ownership of the [`Result`]
263+
//! and apply the provided function to make a decision.
264+
//! The methods return the same boolean value as the function returns.
261265
//!
262266
//! [`is_err`]: Result::is_err
263267
//! [`is_ok`]: Result::is_ok
268+
//! [`is_ok_and`]: Result::is_ok_and
269+
//! [`is_err_and`]: Result::is_err_and
270+
//!
271+
//! ## Inspecting the variant
272+
//!
273+
//! The [`inspect`] and [`inspect_err`] methods take ownership of the [`Result`]
274+
//! and apply the provided function to the contained value by reference if [`Ok`]
275+
//! or [`Err`], respectively. And then, the [`Result`] is returned.
276+
//!
277+
//! [`inspect`]: Result::inspect
278+
//! [`inspect_err`]: Result::inspect_err
264279
//!
265280
//! ## Adapters for working with references
266281
//!
@@ -287,6 +302,7 @@
287302
//! (which must implement the [`Default`] trait)
288303
//! * [`unwrap_or_else`] returns the result of evaluating the provided
289304
//! function
305+
//! * [`unwrap_unchecked`] is *[undefined behavior]*
290306
//!
291307
//! The panicking methods [`expect`] and [`unwrap`] require `E` to
292308
//! implement the [`Debug`] trait.
@@ -297,17 +313,22 @@
297313
//! [`unwrap_or`]: Result::unwrap_or
298314
//! [`unwrap_or_default`]: Result::unwrap_or_default
299315
//! [`unwrap_or_else`]: Result::unwrap_or_else
316+
//! [`unwrap_unchecked`]: Result::unwrap_unchecked
317+
//! [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
300318
//!
301319
//! These methods extract the contained value in a [`Result<T, E>`] when it
302320
//! is the [`Err`] variant. They require `T` to implement the [`Debug`]
303321
//! trait. If the [`Result`] is [`Ok`]:
304322
//!
305323
//! * [`expect_err`] panics with a provided custom message
306324
//! * [`unwrap_err`] panics with a generic message
325+
//! * [`unwrap_err_unchecked`] is *[undefined behavior]*
307326
//!
308327
//! [`Debug`]: crate::fmt::Debug
309328
//! [`expect_err`]: Result::expect_err
310329
//! [`unwrap_err`]: Result::unwrap_err
330+
//! [`unwrap_err_unchecked`]: Result::unwrap_err_unchecked
331+
//! [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
311332
//!
312333
//! ## Transforming contained values
313334
//!

0 commit comments

Comments
 (0)