|
256 | 256 | //!
|
257 | 257 | //! ## Querying the variant
|
258 | 258 | //!
|
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. |
261 | 265 | //!
|
262 | 266 | //! [`is_err`]: Result::is_err
|
263 | 267 | //! [`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 |
264 | 279 | //!
|
265 | 280 | //! ## Adapters for working with references
|
266 | 281 | //!
|
|
287 | 302 | //! (which must implement the [`Default`] trait)
|
288 | 303 | //! * [`unwrap_or_else`] returns the result of evaluating the provided
|
289 | 304 | //! function
|
| 305 | +//! * [`unwrap_unchecked`] is *[undefined behavior]* |
290 | 306 | //!
|
291 | 307 | //! The panicking methods [`expect`] and [`unwrap`] require `E` to
|
292 | 308 | //! implement the [`Debug`] trait.
|
|
297 | 313 | //! [`unwrap_or`]: Result::unwrap_or
|
298 | 314 | //! [`unwrap_or_default`]: Result::unwrap_or_default
|
299 | 315 | //! [`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 |
300 | 318 | //!
|
301 | 319 | //! These methods extract the contained value in a [`Result<T, E>`] when it
|
302 | 320 | //! is the [`Err`] variant. They require `T` to implement the [`Debug`]
|
303 | 321 | //! trait. If the [`Result`] is [`Ok`]:
|
304 | 322 | //!
|
305 | 323 | //! * [`expect_err`] panics with a provided custom message
|
306 | 324 | //! * [`unwrap_err`] panics with a generic message
|
| 325 | +//! * [`unwrap_err_unchecked`] is *[undefined behavior]* |
307 | 326 | //!
|
308 | 327 | //! [`Debug`]: crate::fmt::Debug
|
309 | 328 | //! [`expect_err`]: Result::expect_err
|
310 | 329 | //! [`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 |
311 | 332 | //!
|
312 | 333 | //! ## Transforming contained values
|
313 | 334 | //!
|
|
0 commit comments