Skip to content

Commit c512829

Browse files
authored
Rollup merge of #62379 - GuillaumeGomez:option-doc-links, r=QuietMisdreavus
Add missing links in Option documentation r? @rust-lang/docs
2 parents 719eeb2 + 02886e2 commit c512829

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/libcore/option.rs

+22-10
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<T> Option<T> {
263263
}
264264

265265

266-
/// Converts from `Pin<&Option<T>>` to `Option<Pin<&T>>`
266+
/// Converts from [`Pin`]`<&Option<T>>` to `Option<`[`Pin`]`<&T>>`.
267267
#[inline]
268268
#[stable(feature = "pin", since = "1.33.0")]
269269
pub fn as_pin_ref<'a>(self: Pin<&'a Option<T>>) -> Option<Pin<&'a T>> {
@@ -272,7 +272,7 @@ impl<T> Option<T> {
272272
}
273273
}
274274

275-
/// Converts from `Pin<&mut Option<T>>` to `Option<Pin<&mut T>>`
275+
/// Converts from [`Pin`]`<&mut Option<T>>` to `Option<`[`Pin`]`<&mut T>>`.
276276
#[inline]
277277
#[stable(feature = "pin", since = "1.33.0")]
278278
pub fn as_pin_mut<'a>(self: Pin<&'a mut Option<T>>) -> Option<Pin<&'a mut T>> {
@@ -626,14 +626,14 @@ impl<T> Option<T> {
626626
}
627627
}
628628

629-
/// Returns `None` if the option is `None`, otherwise calls `predicate`
629+
/// Returns [`None`] if the option is [`None`], otherwise calls `predicate`
630630
/// with the wrapped value and returns:
631631
///
632-
/// - `Some(t)` if `predicate` returns `true` (where `t` is the wrapped
632+
/// - [`Some(t)`] if `predicate` returns `true` (where `t` is the wrapped
633633
/// value), and
634-
/// - `None` if `predicate` returns `false`.
634+
/// - [`None`] if `predicate` returns `false`.
635635
///
636-
/// This function works similar to `Iterator::filter()`. You can imagine
636+
/// This function works similar to [`Iterator::filter()`]. You can imagine
637637
/// the `Option<T>` being an iterator over one or zero elements. `filter()`
638638
/// lets you decide which elements to keep.
639639
///
@@ -648,6 +648,10 @@ impl<T> Option<T> {
648648
/// assert_eq!(Some(3).filter(is_even), None);
649649
/// assert_eq!(Some(4).filter(is_even), Some(4));
650650
/// ```
651+
///
652+
/// [`None`]: #variant.None
653+
/// [`Some(t)`]: #variant.Some
654+
/// [`Iterator::filter()`]: ../../std/iter/trait.Iterator.html#method.filter
651655
#[inline]
652656
#[stable(feature = "option_filter", since = "1.27.0")]
653657
pub fn filter<P: FnOnce(&T) -> bool>(self, predicate: P) -> Self {
@@ -986,17 +990,25 @@ impl<T: Deref> Option<T> {
986990
/// Converts from `&Option<T>` to `Option<&T::Target>`.
987991
///
988992
/// Leaves the original Option in-place, creating a new one with a reference
989-
/// to the original one, additionally coercing the contents via `Deref`.
993+
/// to the original one, additionally coercing the contents via [`Deref`].
994+
///
995+
/// [`Deref`]: ../../std/ops/trait.Deref.html
990996
pub fn deref(&self) -> Option<&T::Target> {
991997
self.as_ref().map(|t| t.deref())
992998
}
993999
}
9941000

9951001
impl<T, E> Option<Result<T, E>> {
996-
/// Transposes an `Option` of a `Result` into a `Result` of an `Option`.
1002+
/// Transposes an `Option` of a [`Result`] into a [`Result`] of an `Option`.
9971003
///
998-
/// `None` will be mapped to `Ok(None)`.
999-
/// `Some(Ok(_))` and `Some(Err(_))` will be mapped to `Ok(Some(_))` and `Err(_)`.
1004+
/// [`None`] will be mapped to [`Ok`]`(`[`None`]`)`.
1005+
/// [`Some`]`(`[`Ok`]`(_))` and [`Some`]`(`[`Err`]`(_))` will be mapped to
1006+
/// [`Ok`]`(`[`Some`]`(_))` and [`Err`]`(_)`.
1007+
///
1008+
/// [`None`]: #variant.None
1009+
/// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
1010+
/// [`Some`]: #variant.Some
1011+
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
10001012
///
10011013
/// # Examples
10021014
///

0 commit comments

Comments
 (0)