Skip to content

Commit 2bbcf92

Browse files
authored
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`.
2 parents b1c782f + 9a3a2a1 commit 2bbcf92

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

library/core/src/option.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ impl<T> Option<T> {
11731173
// Entry-like operations to insert a value and return a reference
11741174
/////////////////////////////////////////////////////////////////////////
11751175

1176-
/// Inserts `value` into the option then returns a mutable reference to it.
1176+
/// Inserts `value` into the option, then returns a mutable reference to it.
11771177
///
11781178
/// If the option already contains a value, the old value is dropped.
11791179
///
@@ -1397,7 +1397,7 @@ impl<T> Option<T> {
13971397
}
13981398

13991399
impl<T, U> Option<(T, U)> {
1400-
/// Unzips an option containing a tuple of two options
1400+
/// Unzips an option containing a tuple of two options.
14011401
///
14021402
/// If `self` is `Some((a, b))` this method returns `(Some(a), Some(b))`.
14031403
/// Otherwise, `(None, None)` is returned.
@@ -1500,7 +1500,7 @@ impl<T: Clone> Option<&mut T> {
15001500
}
15011501

15021502
impl<T: Default> Option<T> {
1503-
/// Returns the contained [`Some`] value or a default
1503+
/// Returns the contained [`Some`] value or a default.
15041504
///
15051505
/// Consumes the `self` argument then, if [`Some`], returns the contained
15061506
/// value, otherwise if [`None`], returns the [default value] for that
@@ -1561,7 +1561,7 @@ impl<T: DerefMut> Option<T> {
15611561
/// Converts from `Option<T>` (or `&mut Option<T>`) to `Option<&mut T::Target>`.
15621562
///
15631563
/// Leaves the original `Option` in-place, creating a new one containing a mutable reference to
1564-
/// the inner type's `Deref::Target` type.
1564+
/// the inner type's [`Deref::Target`] type.
15651565
///
15661566
/// # Examples
15671567
///
@@ -1701,7 +1701,7 @@ impl<'a, T> IntoIterator for &'a mut Option<T> {
17011701

17021702
#[stable(since = "1.12.0", feature = "option_from")]
17031703
impl<T> From<T> for Option<T> {
1704-
/// Copies `val` into a new `Some`.
1704+
/// Moves `val` into a new [`Some`].
17051705
///
17061706
/// # Examples
17071707
///
@@ -1942,8 +1942,8 @@ unsafe impl<A> TrustedLen for IntoIter<A> {}
19421942
impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
19431943
/// Takes each element in the [`Iterator`]: if it is [`None`][Option::None],
19441944
/// no further elements are taken, and the [`None`][Option::None] is
1945-
/// returned. Should no [`None`][Option::None] occur, a container with the
1946-
/// values of each [`Option`] is returned.
1945+
/// returned. Should no [`None`][Option::None] occur, a container of type
1946+
/// `V` containing the values of each [`Option`] is returned.
19471947
///
19481948
/// # Examples
19491949
///
@@ -2039,7 +2039,7 @@ impl<T> ops::FromResidual for Option<T> {
20392039
}
20402040

20412041
impl<T> Option<Option<T>> {
2042-
/// Converts from `Option<Option<T>>` to `Option<T>`
2042+
/// Converts from `Option<Option<T>>` to `Option<T>`.
20432043
///
20442044
/// # Examples
20452045
///

0 commit comments

Comments
 (0)