|
256 | 256 | //!
|
257 | 257 | //! ## Querying the variant
|
258 | 258 | //!
|
259 |
| -//! The [`is_ok`] and [`is_err`] methods take the borrow of the [`Result`] |
| 259 | +//! The [`is_ok`] and [`is_err`] methods borrow of the [`Result`] |
260 | 260 | //! and return [`true`] if the [`Result`] is [`Ok`] or [`Err`], respectively.
|
261 | 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. |
| 262 | +//! The [`is_ok_and`] and [`is_err_and`] methods apply the provided function |
| 263 | +//! to the contents of the [`Result`] to produce a boolean value. If this is [`Err`] |
| 264 | +//! then a default result is returned instead without executing the function. |
265 | 265 | //!
|
266 | 266 | //! [`is_err`]: Result::is_err
|
267 | 267 | //! [`is_ok`]: Result::is_ok
|
268 | 268 | //! [`is_ok_and`]: Result::is_ok_and
|
269 | 269 | //! [`is_err_and`]: Result::is_err_and
|
270 | 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 |
279 |
| -//! |
280 | 271 | //! ## Adapters for working with references
|
281 | 272 | //!
|
282 | 273 | //! * [`as_ref`] converts from `&Result<T, E>` to `Result<&T, &E>`
|
|
302 | 293 | //! (which must implement the [`Default`] trait)
|
303 | 294 | //! * [`unwrap_or_else`] returns the result of evaluating the provided
|
304 | 295 | //! function
|
305 |
| -//! * [`unwrap_unchecked`] is *[undefined behavior]* |
| 296 | +//! * [`unwrap_unchecked`] produces *[undefined behavior]* |
306 | 297 | //!
|
307 | 298 | //! The panicking methods [`expect`] and [`unwrap`] require `E` to
|
308 | 299 | //! implement the [`Debug`] trait.
|
|
322 | 313 | //!
|
323 | 314 | //! * [`expect_err`] panics with a provided custom message
|
324 | 315 | //! * [`unwrap_err`] panics with a generic message
|
325 |
| -//! * [`unwrap_err_unchecked`] is *[undefined behavior]* |
| 316 | +//! * [`unwrap_err_unchecked`] produces *[undefined behavior]* |
326 | 317 | //!
|
327 | 318 | //! [`Debug`]: crate::fmt::Debug
|
328 | 319 | //! [`expect_err`]: Result::expect_err
|
|
356 | 347 | //! * [`map`] transforms [`Result<T, E>`] into [`Result<U, E>`] by applying
|
357 | 348 | //! the provided function to the contained value of [`Ok`] and leaving
|
358 | 349 | //! [`Err`] values unchanged
|
| 350 | +//! * [`inspect`] takes ownership of the [`Result`] and applies the |
| 351 | +//! provided function to the contained value by reference, |
| 352 | +//! and then the [`Result`] is returned |
359 | 353 | //!
|
360 | 354 | //! [`map`]: Result::map
|
| 355 | +//! [`inspect`]: Result::inspect |
361 | 356 | //!
|
362 | 357 | //! This method transforms the contained value of the [`Err`] variant:
|
363 | 358 | //!
|
364 | 359 | //! * [`map_err`] transforms [`Result<T, E>`] into [`Result<T, F>`] by
|
365 | 360 | //! applying the provided function to the contained value of [`Err`] and
|
366 | 361 | //! leaving [`Ok`] values unchanged
|
| 362 | +//! * [`inspect_err`] takes ownership of the [`Result`] and applies the |
| 363 | +//! provided function to the contained value of [`Err`] by reference, |
| 364 | +//! and then the [`Result`] is returned |
367 | 365 | //!
|
368 | 366 | //! [`map_err`]: Result::map_err
|
| 367 | +//! [`inspect_err`]: Result::inspect_err |
369 | 368 | //!
|
370 | 369 | //! These methods transform a [`Result<T, E>`] into a value of a possibly
|
371 | 370 | //! different type `U`:
|
|
0 commit comments