about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJack Huey <31162821+jackh726@users.noreply.github.com>2021-09-08 12:24:18 -0400
committerGitHub <noreply@github.com>2021-09-08 12:24:18 -0400
commit2bbcf929c6cce88ae4b5be95dcf8d1e6aa25e7cf (patch)
treeffccfd82da1385d30907e773a02e485429de93a1
parentb1c782f20b99bddf4244d0228fff401e1215f4df (diff)
parent9a3a2a1c3784905eee405becdbd2e5c7ebd5dbce (diff)
downloadrust-2bbcf929c6cce88ae4b5be95dcf8d1e6aa25e7cf.tar.gz
rust-2bbcf929c6cce88ae4b5be95dcf8d1e6aa25e7cf.zip
Rollup merge of #88648 - kpreid:option, r=Mark-Simulacrum
Correct “copies” to “moves” in `<Option<T> as From<T>>::from` doc, and other copyediting

The `impl<T> From<T> for Option<T>` has no `Copy` or `Clone` bound, so its operation is guaranteed to be a move. The call site might copy, but the function itself cannot.

Since that would have been a rather small PR, I also reviewed the other documentation in the file and made other improvements (in separate commits): adding periods and commas, linking `Deref::Target`, and clarifying what "a container" is in `FromIterator`.
-rw-r--r--library/core/src/option.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/library/core/src/option.rs b/library/core/src/option.rs
index 9d5e03dd0de..907726f0c34 100644
--- a/library/core/src/option.rs
+++ b/library/core/src/option.rs
@@ -1173,7 +1173,7 @@ impl<T> Option<T> {
     // Entry-like operations to insert a value and return a reference
     /////////////////////////////////////////////////////////////////////////
 
-    /// Inserts `value` into the option then returns a mutable reference to it.
+    /// Inserts `value` into the option, then returns a mutable reference to it.
     ///
     /// If the option already contains a value, the old value is dropped.
     ///
@@ -1397,7 +1397,7 @@ impl<T> Option<T> {
 }
 
 impl<T, U> Option<(T, U)> {
-    /// Unzips an option containing a tuple of two options
+    /// Unzips an option containing a tuple of two options.
     ///
     /// If `self` is `Some((a, b))` this method returns `(Some(a), Some(b))`.
     /// Otherwise, `(None, None)` is returned.
@@ -1500,7 +1500,7 @@ impl<T: Clone> Option<&mut T> {
 }
 
 impl<T: Default> Option<T> {
-    /// Returns the contained [`Some`] value or a default
+    /// Returns the contained [`Some`] value or a default.
     ///
     /// Consumes the `self` argument then, if [`Some`], returns the contained
     /// value, otherwise if [`None`], returns the [default value] for that
@@ -1561,7 +1561,7 @@ impl<T: DerefMut> Option<T> {
     /// Converts from `Option<T>` (or `&mut Option<T>`) to `Option<&mut T::Target>`.
     ///
     /// Leaves the original `Option` in-place, creating a new one containing a mutable reference to
-    /// the inner type's `Deref::Target` type.
+    /// the inner type's [`Deref::Target`] type.
     ///
     /// # Examples
     ///
@@ -1701,7 +1701,7 @@ impl<'a, T> IntoIterator for &'a mut Option<T> {
 
 #[stable(since = "1.12.0", feature = "option_from")]
 impl<T> From<T> for Option<T> {
-    /// Copies `val` into a new `Some`.
+    /// Moves `val` into a new [`Some`].
     ///
     /// # Examples
     ///
@@ -1942,8 +1942,8 @@ unsafe impl<A> TrustedLen for IntoIter<A> {}
 impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
     /// Takes each element in the [`Iterator`]: if it is [`None`][Option::None],
     /// no further elements are taken, and the [`None`][Option::None] is
-    /// returned. Should no [`None`][Option::None] occur, a container with the
-    /// values of each [`Option`] is returned.
+    /// returned. Should no [`None`][Option::None] occur, a container of type
+    /// `V` containing the values of each [`Option`] is returned.
     ///
     /// # Examples
     ///
@@ -2039,7 +2039,7 @@ impl<T> ops::FromResidual for Option<T> {
 }
 
 impl<T> Option<Option<T>> {
-    /// Converts from `Option<Option<T>>` to `Option<T>`
+    /// Converts from `Option<Option<T>>` to `Option<T>`.
     ///
     /// # Examples
     ///