@@ -174,7 +174,7 @@ impl<T> Option<T> {
174174 // Querying the contained values
175175 /////////////////////////////////////////////////////////////////////////
176176
177- /// Returns `true` if the option is a `Some` value.
177+ /// Returns `true` if the option is a [ `Some`] value.
178178 ///
179179 /// # Examples
180180 ///
@@ -185,6 +185,8 @@ impl<T> Option<T> {
185185 /// let x: Option<u32> = None;
186186 /// assert_eq!(x.is_some(), false);
187187 /// ```
188+ ///
189+ /// [`Some`]: #variant.Some
188190 #[ inline]
189191 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
190192 pub fn is_some ( & self ) -> bool {
@@ -194,7 +196,7 @@ impl<T> Option<T> {
194196 }
195197 }
196198
197- /// Returns `true` if the option is a `None` value.
199+ /// Returns `true` if the option is a [ `None`] value.
198200 ///
199201 /// # Examples
200202 ///
@@ -205,6 +207,8 @@ impl<T> Option<T> {
205207 /// let x: Option<u32> = None;
206208 /// assert_eq!(x.is_none(), true);
207209 /// ```
210+ ///
211+ /// [`None`]: #variant.None
208212 #[ inline]
209213 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
210214 pub fn is_none ( & self ) -> bool {
@@ -269,13 +273,14 @@ impl<T> Option<T> {
269273 // Getting to contained values
270274 /////////////////////////////////////////////////////////////////////////
271275
272- /// Unwraps an option, yielding the content of a `Some`.
276+ /// Unwraps an option, yielding the content of a [ `Some`] .
273277 ///
274278 /// # Panics
275279 ///
276280 /// Panics if the value is a [`None`] with a custom panic message provided by
277281 /// `msg`.
278282 ///
283+ /// [`Some`]: #variant.Some
279284 /// [`None`]: #variant.None
280285 ///
281286 /// # Examples
@@ -298,16 +303,17 @@ impl<T> Option<T> {
298303 }
299304 }
300305
301- /// Moves the value `v` out of the `Option<T>` if it is `Some(v)`.
306+ /// Moves the value `v` out of the `Option<T>` if it is [ `Some(v)`] .
302307 ///
303308 /// In general, because this function may panic, its use is discouraged.
304- /// Instead, prefer to use pattern matching and handle the `None`
309+ /// Instead, prefer to use pattern matching and handle the [ `None`]
305310 /// case explicitly.
306311 ///
307312 /// # Panics
308313 ///
309314 /// Panics if the self value equals [`None`].
310315 ///
316+ /// [`Some(v)`]: #variant.Some
311317 /// [`None`]: #variant.None
312318 ///
313319 /// # Examples
@@ -395,7 +401,9 @@ impl<T> Option<T> {
395401 }
396402
397403 /// Applies a function to the contained value (if any),
398- /// or returns a `default` (if not).
404+ /// or returns a [`default`][] (if not).
405+ ///
406+ /// [`default`]: ../default/trait.Default.html#tymethod.default
399407 ///
400408 /// # Examples
401409 ///
@@ -416,7 +424,9 @@ impl<T> Option<T> {
416424 }
417425
418426 /// Applies a function to the contained value (if any),
419- /// or computes a `default` (if not).
427+ /// or computes a [`default`][] (if not).
428+ ///
429+ /// [`default`]: ../default/trait.Default.html#tymethod.default
420430 ///
421431 /// # Examples
422432 ///
@@ -438,12 +448,14 @@ impl<T> Option<T> {
438448 }
439449 }
440450
441- /// Transforms the `Option<T>` into a [`Result<T, E>`], mapping `Some(v)` to
442- /// [`Ok(v)`] and `None` to [`Err(err)`][Err ].
451+ /// Transforms the `Option<T>` into a [`Result<T, E>`], mapping [ `Some(v)`] to
452+ /// [`Ok(v)`] and [ `None`] to [`Err(err)`].
443453 ///
444454 /// [`Result<T, E>`]: ../../std/result/enum.Result.html
445455 /// [`Ok(v)`]: ../../std/result/enum.Result.html#variant.Ok
446- /// [Err]: ../../std/result/enum.Result.html#variant.Err
456+ /// [`Err(err)`]: ../../std/result/enum.Result.html#variant.Err
457+ /// [`None`]: #variant.None
458+ /// [`Some(v)`]: #variant.Some
447459 ///
448460 /// # Examples
449461 ///
@@ -463,12 +475,14 @@ impl<T> Option<T> {
463475 }
464476 }
465477
466- /// Transforms the `Option<T>` into a [`Result<T, E>`], mapping `Some(v)` to
467- /// [`Ok(v)`] and `None` to [`Err(err())`][Err ].
478+ /// Transforms the `Option<T>` into a [`Result<T, E>`], mapping [ `Some(v)`] to
479+ /// [`Ok(v)`] and [ `None`] to [`Err(err())`].
468480 ///
469481 /// [`Result<T, E>`]: ../../std/result/enum.Result.html
470482 /// [`Ok(v)`]: ../../std/result/enum.Result.html#variant.Ok
471- /// [Err]: ../../std/result/enum.Result.html#variant.Err
483+ /// [`Err(err())`]: ../../std/result/enum.Result.html#variant.Err
484+ /// [`None`]: #variant.None
485+ /// [`Some(v)`]: #variant.Some
472486 ///
473487 /// # Examples
474488 ///
@@ -534,7 +548,9 @@ impl<T> Option<T> {
534548 // Boolean operations on the values, eager and lazy
535549 /////////////////////////////////////////////////////////////////////////
536550
537- /// Returns `None` if the option is `None`, otherwise returns `optb`.
551+ /// Returns [`None`] if the option is [`None`], otherwise returns `optb`.
552+ ///
553+ /// [`None`]: #variant.None
538554 ///
539555 /// # Examples
540556 ///
@@ -564,11 +580,13 @@ impl<T> Option<T> {
564580 }
565581 }
566582
567- /// Returns `None` if the option is `None`, otherwise calls `f` with the
583+ /// Returns [ `None`] if the option is [ `None`] , otherwise calls `f` with the
568584 /// wrapped value and returns the result.
569585 ///
570586 /// Some languages call this operation flatmap.
571587 ///
588+ /// [`None`]: #variant.None
589+ ///
572590 /// # Examples
573591 ///
574592 /// ```
@@ -645,9 +663,11 @@ impl<T> Option<T> {
645663 // Entry-like operations to insert if None and return a reference
646664 /////////////////////////////////////////////////////////////////////////
647665
648- /// Inserts `v` into the option if it is `None`, then
666+ /// Inserts `v` into the option if it is [ `None`] , then
649667 /// returns a mutable reference to the contained value.
650668 ///
669+ /// [`None`]: #variant.None
670+ ///
651671 /// # Examples
652672 ///
653673 /// ```
@@ -678,9 +698,11 @@ impl<T> Option<T> {
678698 }
679699 }
680700
681- /// Inserts a value computed from `f` into the option if it is `None`, then
701+ /// Inserts a value computed from `f` into the option if it is [ `None`] , then
682702 /// returns a mutable reference to the contained value.
683703 ///
704+ /// [`None`]: #variant.None
705+ ///
684706 /// # Examples
685707 ///
686708 /// ```
@@ -715,7 +737,9 @@ impl<T> Option<T> {
715737 // Misc
716738 /////////////////////////////////////////////////////////////////////////
717739
718- /// Takes the value out of the option, leaving a `None` in its place.
740+ /// Takes the value out of the option, leaving a [`None`] in its place.
741+ ///
742+ /// [`None`]: #variant.None
719743 ///
720744 /// # Examples
721745 ///
@@ -757,16 +781,16 @@ impl<'a, T: Clone> Option<&'a T> {
757781impl < T : Default > Option < T > {
758782 /// Returns the contained value or a default
759783 ///
760- /// Consumes the `self` argument then, if `Some`, returns the contained
761- /// value, otherwise if `None`, returns the default value for that
784+ /// Consumes the `self` argument then, if [ `Some`] , returns the contained
785+ /// value, otherwise if [ `None`] , returns the default value for that
762786 /// type.
763787 ///
764788 /// # Examples
765789 ///
766790 /// Convert a string to an integer, turning poorly-formed strings
767- /// into 0 (the default value for integers). `parse` converts
768- /// a string to any other type that implements `FromStr`, returning
769- /// `None` on error.
791+ /// into 0 (the default value for integers). [ `parse`] converts
792+ /// a string to any other type that implements [ `FromStr`] , returning
793+ /// [ `None`] on error.
770794 ///
771795 /// ```
772796 /// let good_year_from_input = "1909";
@@ -777,6 +801,11 @@ impl<T: Default> Option<T> {
777801 /// assert_eq!(1909, good_year);
778802 /// assert_eq!(0, bad_year);
779803 /// ```
804+ ///
805+ /// [`Some`]: #variant.Some
806+ /// [`None`]: #variant.None
807+ /// [`parse`]: ../../std/primitive.str.html#method.parse
808+ /// [`FromStr`]: ../../std/str/trait.FromStr.html
780809 #[ inline]
781810 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
782811 pub fn unwrap_or_default ( self ) -> T {
@@ -801,7 +830,9 @@ fn expect_failed(msg: &str) -> ! {
801830
802831#[ stable( feature = "rust1" , since = "1.0.0" ) ]
803832impl < T > Default for Option < T > {
804- /// Returns None.
833+ /// Returns [`None`].
834+ ///
835+ /// [`None`]: #variant.None
805836 #[ inline]
806837 fn default ( ) -> Option < T > { None }
807838}
@@ -1020,8 +1051,8 @@ unsafe impl<A> TrustedLen for IntoIter<A> {}
10201051
10211052#[ stable( feature = "rust1" , since = "1.0.0" ) ]
10221053impl < A , V : FromIterator < A > > FromIterator < Option < A > > for Option < V > {
1023- /// Takes each element in the `Iterator`: if it is `None`, no further
1024- /// elements are taken, and the `None` is returned. Should no `None` occur, a
1054+ /// Takes each element in the [ `Iterator`] : if it is [ `None`] , no further
1055+ /// elements are taken, and the [ `None`] is returned. Should no [ `None`] occur, a
10251056 /// container with the values of each `Option` is returned.
10261057 ///
10271058 /// Here is an example which increments every integer in a vector,
@@ -1037,6 +1068,9 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
10371068 /// ).collect();
10381069 /// assert!(res == Some(vec![2, 3]));
10391070 /// ```
1071+ ///
1072+ /// [`Iterator`]: ../iter/trait.Iterator.html
1073+ /// [`None`]: enum.Option.html#variant.None
10401074 #[ inline]
10411075 fn from_iter < I : IntoIterator < Item =Option < A > > > ( iter : I ) -> Option < V > {
10421076 // FIXME(#11084): This could be replaced with Iterator::scan when this
0 commit comments