From 74e7709485c7597ff7446ac9b420153e22f834fc Mon Sep 17 00:00:00 2001 From: Zachary Mayhew Date: Sat, 26 Nov 2022 15:41:48 -0800 Subject: [PATCH 1/2] reword Option::as_ref and Option::map examples --- library/core/src/option.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 505d964e518d7..6bfe34390cc48 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -608,10 +608,10 @@ impl Option { /// /// # Examples /// - /// Converts an Option<[String]> into an Option<[usize]>, preserving - /// the original. The [`map`] method takes the `self` argument by value, consuming the original, - /// so this technique uses `as_ref` to first take an `Option` to a reference - /// to the value inside the original. + /// Calculates the length of an Option<[String]> as an Option<[usize]> + /// without moving the [`String`]. The [`map`] method takes the `self` argument by value, + /// consuming the original, so this technique uses `as_ref` to first take an `Option` to a + /// reference to the value inside the original. /// /// [`map`]: Option::map /// [String]: ../../std/string/struct.String.html "String" @@ -902,8 +902,8 @@ impl Option { /// /// # Examples /// - /// Converts an Option<[String]> into an Option<[usize]>, consuming - /// the original: + /// Calculates the length of an Option<[String]> as an + /// Option<[usize]>, consuming the original: /// /// [String]: ../../std/string/struct.String.html "String" /// ``` From 123e2038d4cd6b29ff3d30cf766e94b67efcb637 Mon Sep 17 00:00:00 2001 From: Zachary Mayhew Date: Sat, 26 Nov 2022 17:30:17 -0800 Subject: [PATCH 2/2] add link for string to as_ref docs --- library/core/src/option.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 6bfe34390cc48..48e6af36ac75a 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -615,6 +615,7 @@ impl Option { /// /// [`map`]: Option::map /// [String]: ../../std/string/struct.String.html "String" + /// [`String`]: ../../std/string/struct.String.html "String" /// /// ``` /// let text: Option = Some("Hello, world!".to_string());