@@ -263,7 +263,7 @@ impl<T> Option<T> {
263
263
}
264
264
265
265
266
- /// Converts from `Pin<&Option<T>>` to `Option<Pin<&T>>`
266
+ /// Converts from [ `Pin`]` <&Option<T>>` to `Option<`[` Pin`]` <&T>>`.
267
267
#[ inline]
268
268
#[ stable( feature = "pin" , since = "1.33.0" ) ]
269
269
pub fn as_pin_ref < ' a > ( self : Pin < & ' a Option < T > > ) -> Option < Pin < & ' a T > > {
@@ -272,7 +272,7 @@ impl<T> Option<T> {
272
272
}
273
273
}
274
274
275
- /// Converts from `Pin<&mut Option<T>>` to `Option<Pin<&mut T>>`
275
+ /// Converts from [ `Pin`]` <&mut Option<T>>` to `Option<`[` Pin`]` <&mut T>>`.
276
276
#[ inline]
277
277
#[ stable( feature = "pin" , since = "1.33.0" ) ]
278
278
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> {
626
626
}
627
627
}
628
628
629
- /// Returns `None` if the option is `None`, otherwise calls `predicate`
629
+ /// Returns [ `None`] if the option is [ `None`] , otherwise calls `predicate`
630
630
/// with the wrapped value and returns:
631
631
///
632
- /// - `Some(t)` if `predicate` returns `true` (where `t` is the wrapped
632
+ /// - [ `Some(t)`] if `predicate` returns `true` (where `t` is the wrapped
633
633
/// value), and
634
- /// - `None` if `predicate` returns `false`.
634
+ /// - [ `None`] if `predicate` returns `false`.
635
635
///
636
- /// This function works similar to `Iterator::filter()`. You can imagine
636
+ /// This function works similar to [ `Iterator::filter()`] . You can imagine
637
637
/// the `Option<T>` being an iterator over one or zero elements. `filter()`
638
638
/// lets you decide which elements to keep.
639
639
///
@@ -648,6 +648,10 @@ impl<T> Option<T> {
648
648
/// assert_eq!(Some(3).filter(is_even), None);
649
649
/// assert_eq!(Some(4).filter(is_even), Some(4));
650
650
/// ```
651
+ ///
652
+ /// [`None`]: #variant.None
653
+ /// [`Some(t)`]: #variant.Some
654
+ /// [`Iterator::filter()`]: ../../std/iter/trait.Iterator.html#method.filter
651
655
#[ inline]
652
656
#[ stable( feature = "option_filter" , since = "1.27.0" ) ]
653
657
pub fn filter < P : FnOnce ( & T ) -> bool > ( self , predicate : P ) -> Self {
@@ -986,17 +990,25 @@ impl<T: Deref> Option<T> {
986
990
/// Converts from `&Option<T>` to `Option<&T::Target>`.
987
991
///
988
992
/// 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
990
996
pub fn deref ( & self ) -> Option < & T :: Target > {
991
997
self . as_ref ( ) . map ( |t| t. deref ( ) )
992
998
}
993
999
}
994
1000
995
1001
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`.
997
1003
///
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
1000
1012
///
1001
1013
/// # Examples
1002
1014
///
0 commit comments