about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev+love@gmail.com>2023-01-14 12:04:31 +0900
committerGitHub <noreply@github.com>2023-01-14 12:04:31 +0900
commit6702f20ca7a117e249d31c96f2c5f48f1bb4eaaa (patch)
tree6fc8607df8bd4dca89260ec9a914008411db75be
parenta11eb4f267ddfe4f00cb40bf94aef508c11e0862 (diff)
parent123e2038d4cd6b29ff3d30cf766e94b67efcb637 (diff)
downloadrust-6702f20ca7a117e249d31c96f2c5f48f1bb4eaaa.tar.gz
rust-6702f20ca7a117e249d31c96f2c5f48f1bb4eaaa.zip
Rollup merge of #104965 - zacklukem:p-option-as_ref-docs, r=scottmcm
reword Option::as_ref and Option::map examples

The description for the examples of `Option::as_ref` and `Option::map` imply that the example is only doing type conversion, when it is actually finding the length of a string.

Changes the wording to imply that some operation is being run on the value contained in the `Option`

closes #104476
-rw-r--r--library/core/src/option.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/library/core/src/option.rs b/library/core/src/option.rs
index 39462dca4ff..7cc00e3f8d1 100644
--- a/library/core/src/option.rs
+++ b/library/core/src/option.rs
@@ -652,13 +652,14 @@ impl<T> Option<T> {
     ///
     /// # Examples
     ///
-    /// Converts an <code>Option<[String]></code> into an <code>Option<[usize]></code>, 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 <code>Option<[String]></code> as an <code>Option<[usize]></code>
+    /// 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"
+    /// [`String`]: ../../std/string/struct.String.html "String"
     ///
     /// ```
     /// let text: Option<String> = Some("Hello, world!".to_string());
@@ -946,8 +947,8 @@ impl<T> Option<T> {
     ///
     /// # Examples
     ///
-    /// Converts an <code>Option<[String]></code> into an <code>Option<[usize]></code>, consuming
-    /// the original:
+    /// Calculates the length of an <code>Option<[String]></code> as an
+    /// <code>Option<[usize]></code>, consuming the original:
     ///
     /// [String]: ../../std/string/struct.String.html "String"
     /// ```