From 34c1fce50be88eb4a0b81eb486b47e1f929b1ce3 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Sat, 4 Sep 2021 11:05:36 -0700 Subject: [PATCH 1/3] =?UTF-8?q?=E2=80=9CMoves=E2=80=9D=20instead=20of=20?= =?UTF-8?q?=E2=80=9Ccopies=E2=80=9D=20in=20`=20as=20From>::fr?= =?UTF-8?q?om`=20doc.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This implementation 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. Also linkify `Some` while we're touching the line anyway. --- library/core/src/option.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 9d5e03dd0de..899a3b83df6 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -1701,7 +1701,7 @@ impl<'a, T> IntoIterator for &'a mut Option { #[stable(since = "1.12.0", feature = "option_from")] impl From for Option { - /// Copies `val` into a new `Some`. + /// Moves `val` into a new [`Some`]. /// /// # Examples /// From c2f432058c8dcf3d210ea673d178b3768815f80d Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Sat, 4 Sep 2021 11:17:34 -0700 Subject: [PATCH 2/3] Add sentence punctuation and links in `Option` docs. --- library/core/src/option.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 899a3b83df6..64333a82387 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -1173,7 +1173,7 @@ impl Option { // 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 Option { } impl 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 Option<&mut T> { } impl Option { - /// 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 Option { /// Converts from `Option` (or `&mut Option`) 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 /// @@ -2039,7 +2039,7 @@ impl ops::FromResidual for Option { } impl Option> { - /// Converts from `Option>` to `Option` + /// Converts from `Option>` to `Option`. /// /// # Examples /// From 9a3a2a1c3784905eee405becdbd2e5c7ebd5dbce Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Sat, 4 Sep 2021 11:19:59 -0700 Subject: [PATCH 3/3] =?UTF-8?q?Clarify=20what=20=E2=80=9Ca=20container?= =?UTF-8?q?=E2=80=9D=20is=20in=20`FromIterator>=20for=20Option`=20doc.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/core/src/option.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 64333a82387..907726f0c34 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -1942,8 +1942,8 @@ unsafe impl TrustedLen for IntoIter {} impl> FromIterator> for Option { /// 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 ///