From d646463a452d77dd7d5e1f8d0830d95bf867863f Mon Sep 17 00:00:00 2001 From: "Tom A. Wagner" Date: Thu, 6 Feb 2020 12:09:16 +0100 Subject: [PATCH] Mark fn map_or() as eagerly evaluated. In the docs for option.rs and result.rs, it is noted for all *_or() functions that they are eagerly evaluated, except for the map_or() function. This commit adds this missing documentation to the two files. --- src/libcore/option.rs | 6 ++++++ src/libcore/result.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index ad0491f888c..e35c91206b8 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -455,6 +455,12 @@ impl Option { /// Applies a function to the contained value (if any), /// or returns the provided default (if not). /// + /// Arguments passed to `map_or` are eagerly evaluated; if you are passing + /// the result of a function call, it is recommended to use [`map_or_else`], + /// which is lazily evaluated. + /// + /// [`map_or_else`]: #method.map_or_else + /// /// # Examples /// /// ``` diff --git a/src/libcore/result.rs b/src/libcore/result.rs index bc70dbd62eb..809d4bace8e 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -524,6 +524,12 @@ impl Result { /// Applies a function to the contained value (if any), /// or returns the provided default (if not). /// + /// Arguments passed to `map_or` are eagerly evaluated; if you are passing + /// the result of a function call, it is recommended to use [`map_or_else`], + /// which is lazily evaluated. + /// + /// [`map_or_else`]: #method.map_or_else + /// /// # Examples /// /// ```