@@ -244,9 +244,12 @@ use fmt;
244244use iter:: { FromIterator , FusedIterator , TrustedLen } ;
245245use ops;
246246
247- /// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
247+ /// `Result` is a type that represents either success ([ `Ok`] ) or failure ([ `Err`] ).
248248///
249249/// See the [`std::result`](index.html) module documentation for details.
250+ ///
251+ /// [`Ok`]: enum.Result.html#variant.Ok
252+ /// [`Err`]: enum.Result.html#variant.Err
250253#[ derive( Clone , Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash ) ]
251254#[ must_use]
252255#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -269,7 +272,9 @@ impl<T, E> Result<T, E> {
269272 // Querying the contained values
270273 /////////////////////////////////////////////////////////////////////////
271274
272- /// Returns `true` if the result is `Ok`.
275+ /// Returns `true` if the result is [`Ok`].
276+ ///
277+ /// [`Ok`]: enum.Result.html#variant.Ok
273278 ///
274279 /// # Examples
275280 ///
@@ -291,7 +296,9 @@ impl<T, E> Result<T, E> {
291296 }
292297 }
293298
294- /// Returns `true` if the result is `Err`.
299+ /// Returns `true` if the result is [`Err`].
300+ ///
301+ /// [`Err`]: enum.Result.html#variant.Err
295302 ///
296303 /// # Examples
297304 ///
@@ -433,10 +440,13 @@ impl<T, E> Result<T, E> {
433440 /////////////////////////////////////////////////////////////////////////
434441
435442 /// Maps a `Result<T, E>` to `Result<U, E>` by applying a function to a
436- /// contained `Ok` value, leaving an `Err` value untouched.
443+ /// contained [ `Ok`] value, leaving an [ `Err`] value untouched.
437444 ///
438445 /// This function can be used to compose the results of two functions.
439446 ///
447+ /// [`Ok`]: enum.Result.html#variant.Ok
448+ /// [`Err`]: enum.Result.html#variant.Err
449+ ///
440450 /// # Examples
441451 ///
442452 /// Print the numbers on each line of a string multiplied by two.
@@ -461,11 +471,14 @@ impl<T, E> Result<T, E> {
461471 }
462472
463473 /// Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
464- /// contained `Err` value, leaving an `Ok` value untouched.
474+ /// contained [ `Err`] value, leaving an [ `Ok`] value untouched.
465475 ///
466476 /// This function can be used to pass through a successful result while handling
467477 /// an error.
468478 ///
479+ /// [`Ok`]: enum.Result.html#variant.Ok
480+ /// [`Err`]: enum.Result.html#variant.Err
481+ ///
469482 /// # Examples
470483 ///
471484 /// Basic usage:
@@ -546,7 +559,10 @@ impl<T, E> Result<T, E> {
546559 // Boolean operations on the values, eager and lazy
547560 /////////////////////////////////////////////////////////////////////////
548561
549- /// Returns `res` if the result is `Ok`, otherwise returns the `Err` value of `self`.
562+ /// Returns `res` if the result is [`Ok`], otherwise returns the [`Err`] value of `self`.
563+ ///
564+ /// [`Ok`]: enum.Result.html#variant.Ok
565+ /// [`Err`]: enum.Result.html#variant.Err
550566 ///
551567 /// # Examples
552568 ///
@@ -578,7 +594,10 @@ impl<T, E> Result<T, E> {
578594 }
579595 }
580596
581- /// Calls `op` if the result is `Ok`, otherwise returns the `Err` value of `self`.
597+ /// Calls `op` if the result is [`Ok`], otherwise returns the [`Err`] value of `self`.
598+ ///
599+ /// [`Ok`]: enum.Result.html#variant.Ok
600+ /// [`Err`]: enum.Result.html#variant.Err
582601 ///
583602 /// This function can be used for control flow based on `Result` values.
584603 ///
@@ -604,7 +623,10 @@ impl<T, E> Result<T, E> {
604623 }
605624 }
606625
607- /// Returns `res` if the result is `Err`, otherwise returns the `Ok` value of `self`.
626+ /// Returns `res` if the result is [`Err`], otherwise returns the [`Ok`] value of `self`.
627+ ///
628+ /// [`Ok`]: enum.Result.html#variant.Ok
629+ /// [`Err`]: enum.Result.html#variant.Err
608630 ///
609631 /// # Examples
610632 ///
@@ -636,10 +658,13 @@ impl<T, E> Result<T, E> {
636658 }
637659 }
638660
639- /// Calls `op` if the result is `Err`, otherwise returns the `Ok` value of `self`.
661+ /// Calls `op` if the result is [ `Err`] , otherwise returns the [ `Ok`] value of `self`.
640662 ///
641663 /// This function can be used for control flow based on result values.
642664 ///
665+ /// [`Ok`]: enum.Result.html#variant.Ok
666+ /// [`Err`]: enum.Result.html#variant.Err
667+ ///
643668 /// # Examples
644669 ///
645670 /// Basic usage:
@@ -662,9 +687,12 @@ impl<T, E> Result<T, E> {
662687 }
663688 }
664689
665- /// Unwraps a result, yielding the content of an `Ok`.
690+ /// Unwraps a result, yielding the content of an [ `Ok`] .
666691 /// Else, it returns `optb`.
667692 ///
693+ /// [`Ok`]: enum.Result.html#variant.Ok
694+ /// [`Err`]: enum.Result.html#variant.Err
695+ ///
668696 /// # Examples
669697 ///
670698 /// Basic usage:
@@ -686,8 +714,11 @@ impl<T, E> Result<T, E> {
686714 }
687715 }
688716
689- /// Unwraps a result, yielding the content of an `Ok`.
690- /// If the value is an `Err` then it calls `op` with its value.
717+ /// Unwraps a result, yielding the content of an [`Ok`].
718+ /// If the value is an [`Err`] then it calls `op` with its value.
719+ ///
720+ /// [`Ok`]: enum.Result.html#variant.Ok
721+ /// [`Err`]: enum.Result.html#variant.Err
691722 ///
692723 /// # Examples
693724 ///
@@ -710,12 +741,15 @@ impl<T, E> Result<T, E> {
710741}
711742
712743impl < T , E : fmt:: Debug > Result < T , E > {
713- /// Unwraps a result, yielding the content of an `Ok`.
744+ /// Unwraps a result, yielding the content of an [ `Ok`] .
714745 ///
715746 /// # Panics
716747 ///
717- /// Panics if the value is an `Err`, with a panic message provided by the
718- /// `Err`'s value.
748+ /// Panics if the value is an [`Err`], with a panic message provided by the
749+ /// [`Err`]'s value.
750+ ///
751+ /// [`Ok`]: enum.Result.html#variant.Ok
752+ /// [`Err`]: enum.Result.html#variant.Err
719753 ///
720754 /// # Examples
721755 ///
@@ -739,12 +773,15 @@ impl<T, E: fmt::Debug> Result<T, E> {
739773 }
740774 }
741775
742- /// Unwraps a result, yielding the content of an `Ok`.
776+ /// Unwraps a result, yielding the content of an [ `Ok`] .
743777 ///
744778 /// # Panics
745779 ///
746- /// Panics if the value is an `Err`, with a panic message including the
747- /// passed message, and the content of the `Err`.
780+ /// Panics if the value is an [`Err`], with a panic message including the
781+ /// passed message, and the content of the [`Err`].
782+ ///
783+ /// [`Ok`]: enum.Result.html#variant.Ok
784+ /// [`Err`]: enum.Result.html#variant.Err
748785 ///
749786 /// # Examples
750787 ///
@@ -765,12 +802,16 @@ impl<T, E: fmt::Debug> Result<T, E> {
765802}
766803
767804impl < T : fmt:: Debug , E > Result < T , E > {
768- /// Unwraps a result, yielding the content of an `Err`.
805+ /// Unwraps a result, yielding the content of an [ `Err`] .
769806 ///
770807 /// # Panics
771808 ///
772- /// Panics if the value is an `Ok`, with a custom panic message provided
773- /// by the `Ok`'s value.
809+ /// Panics if the value is an [`Ok`], with a custom panic message provided
810+ /// by the [`Ok`]'s value.
811+ ///
812+ /// [`Ok`]: enum.Result.html#variant.Ok
813+ /// [`Err`]: enum.Result.html#variant.Err
814+ ///
774815 ///
775816 /// # Examples
776817 ///
@@ -792,12 +833,15 @@ impl<T: fmt::Debug, E> Result<T, E> {
792833 }
793834 }
794835
795- /// Unwraps a result, yielding the content of an `Err`.
836+ /// Unwraps a result, yielding the content of an [ `Err`] .
796837 ///
797838 /// # Panics
798839 ///
799- /// Panics if the value is an `Ok`, with a panic message including the
800- /// passed message, and the content of the `Ok`.
840+ /// Panics if the value is an [`Ok`], with a panic message including the
841+ /// passed message, and the content of the [`Ok`].
842+ ///
843+ /// [`Ok`]: enum.Result.html#variant.Ok
844+ /// [`Err`]: enum.Result.html#variant.Err
801845 ///
802846 /// # Examples
803847 ///
@@ -820,16 +864,16 @@ impl<T: fmt::Debug, E> Result<T, E> {
820864impl < T : Default , E > Result < T , E > {
821865 /// Returns the contained value or a default
822866 ///
823- /// Consumes the `self` argument then, if `Ok`, returns the contained
824- /// value, otherwise if `Err`, returns the default value for that
867+ /// Consumes the `self` argument then, if [ `Ok`] , returns the contained
868+ /// value, otherwise if [ `Err`] , returns the default value for that
825869 /// type.
826870 ///
827871 /// # Examples
828872 ///
829873 /// Convert a string to an integer, turning poorly-formed strings
830874 /// into 0 (the default value for integers). [`parse`] converts
831875 /// a string to any other type that implements [`FromStr`], returning an
832- /// `Err` on error.
876+ /// [ `Err`] on error.
833877 ///
834878 /// ```
835879 /// let good_year_from_input = "1909";
@@ -843,6 +887,8 @@ impl<T: Default, E> Result<T, E> {
843887 ///
844888 /// [`parse`]: ../../std/primitive.str.html#method.parse
845889 /// [`FromStr`]: ../../std/str/trait.FromStr.html
890+ /// [`Ok`]: enum.Result.html#variant.Ok
891+ /// [`Err`]: enum.Result.html#variant.Err
846892 #[ inline]
847893 #[ stable( feature = "result_unwrap_or_default" , since = "1.16.0" ) ]
848894 pub fn unwrap_or_default ( self ) -> T {
0 commit comments