@@ -338,6 +338,12 @@ impl<T> Option<T> {
338
338
339
339
/// Returns the contained value or a default.
340
340
///
341
+ /// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing
342
+ /// the result of a function call, it is recommended to use [`unwrap_or_else`],
343
+ /// which is lazily evaluated.
344
+ ///
345
+ /// [`unwrap_or_else`]: #method.unwrap_or_else
346
+ ///
341
347
/// # Examples
342
348
///
343
349
/// ```
@@ -451,11 +457,16 @@ impl<T> Option<T> {
451
457
/// Transforms the `Option<T>` into a [`Result<T, E>`], mapping [`Some(v)`] to
452
458
/// [`Ok(v)`] and [`None`] to [`Err(err)`].
453
459
///
460
+ /// Arguments passed to `ok_or` are eagerly evaluated; if you are passing the
461
+ /// result of a function call, it is recommended to use [`ok_or_else`], which is
462
+ /// lazily evaluated.
463
+ ///
454
464
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
455
465
/// [`Ok(v)`]: ../../std/result/enum.Result.html#variant.Ok
456
466
/// [`Err(err)`]: ../../std/result/enum.Result.html#variant.Err
457
467
/// [`None`]: #variant.None
458
468
/// [`Some(v)`]: #variant.Some
469
+ /// [`ok_or_else`]: #method.ok_or_else
459
470
///
460
471
/// # Examples
461
472
///
@@ -644,6 +655,12 @@ impl<T> Option<T> {
644
655
645
656
/// Returns the option if it contains a value, otherwise returns `optb`.
646
657
///
658
+ /// Arguments passed to `or` are eagerly evaluated; if you are passing the
659
+ /// result of a function call, it is recommended to use [`or_else`], which is
660
+ /// lazily evaluated.
661
+ ///
662
+ /// [`or_else`]: #method.or_else
663
+ ///
647
664
/// # Examples
648
665
///
649
666
/// ```
0 commit comments