Add missing urls for Result struct

This commit is contained in:
Guillaume Gomez 2017-08-18 16:41:54 +02:00
parent 86fd9a552d
commit a5a1739945

View File

@ -244,9 +244,12 @@ use fmt;
use iter::{FromIterator, FusedIterator, TrustedLen}; use iter::{FromIterator, FusedIterator, TrustedLen};
use ops; use ops;
/// `Result` is a type that represents either success (`Ok`) or failure (`Err`). /// `Result` is a type that represents either success ([`Ok`]) or failure ([`Err`]).
/// ///
/// See the [`std::result`](index.html) module documentation for details. /// See the [`std::result`](index.html) module documentation for details.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
#[must_use] #[must_use]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
@ -269,7 +272,9 @@ impl<T, E> Result<T, E> {
// Querying the contained values // Querying the contained values
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
/// Returns `true` if the result is `Ok`. /// Returns `true` if the result is [`Ok`].
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// ///
/// # Examples /// # Examples
/// ///
@ -291,7 +296,9 @@ impl<T, E> Result<T, E> {
} }
} }
/// Returns `true` if the result is `Err`. /// Returns `true` if the result is [`Err`].
///
/// [`Err`]: enum.Result.html#variant.Err
/// ///
/// # Examples /// # Examples
/// ///
@ -433,10 +440,13 @@ impl<T, E> Result<T, E> {
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
/// Maps a `Result<T, E>` to `Result<U, E>` by applying a function to a /// Maps a `Result<T, E>` to `Result<U, E>` by applying a function to a
/// contained `Ok` value, leaving an `Err` value untouched. /// contained [`Ok`] value, leaving an [`Err`] value untouched.
/// ///
/// This function can be used to compose the results of two functions. /// This function can be used to compose the results of two functions.
/// ///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
///
/// # Examples /// # Examples
/// ///
/// Print the numbers on each line of a string multiplied by two. /// Print the numbers on each line of a string multiplied by two.
@ -461,11 +471,14 @@ impl<T, E> Result<T, E> {
} }
/// Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a /// Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
/// contained `Err` value, leaving an `Ok` value untouched. /// contained [`Err`] value, leaving an [`Ok`] value untouched.
/// ///
/// This function can be used to pass through a successful result while handling /// This function can be used to pass through a successful result while handling
/// an error. /// an error.
/// ///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
///
/// # Examples /// # Examples
/// ///
/// Basic usage: /// Basic usage:
@ -546,7 +559,10 @@ impl<T, E> Result<T, E> {
// Boolean operations on the values, eager and lazy // Boolean operations on the values, eager and lazy
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
/// Returns `res` if the result is `Ok`, otherwise returns the `Err` value of `self`. /// Returns `res` if the result is [`Ok`], otherwise returns the [`Err`] value of `self`.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// ///
/// # Examples /// # Examples
/// ///
@ -578,7 +594,10 @@ impl<T, E> Result<T, E> {
} }
} }
/// Calls `op` if the result is `Ok`, otherwise returns the `Err` value of `self`. /// Calls `op` if the result is [`Ok`], otherwise returns the [`Err`] value of `self`.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// ///
/// This function can be used for control flow based on `Result` values. /// This function can be used for control flow based on `Result` values.
/// ///
@ -604,7 +623,10 @@ impl<T, E> Result<T, E> {
} }
} }
/// Returns `res` if the result is `Err`, otherwise returns the `Ok` value of `self`. /// Returns `res` if the result is [`Err`], otherwise returns the [`Ok`] value of `self`.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// ///
/// # Examples /// # Examples
/// ///
@ -636,10 +658,13 @@ impl<T, E> Result<T, E> {
} }
} }
/// Calls `op` if the result is `Err`, otherwise returns the `Ok` value of `self`. /// Calls `op` if the result is [`Err`], otherwise returns the [`Ok`] value of `self`.
/// ///
/// This function can be used for control flow based on result values. /// This function can be used for control flow based on result values.
/// ///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
///
/// # Examples /// # Examples
/// ///
/// Basic usage: /// Basic usage:
@ -662,9 +687,12 @@ impl<T, E> Result<T, E> {
} }
} }
/// Unwraps a result, yielding the content of an `Ok`. /// Unwraps a result, yielding the content of an [`Ok`].
/// Else, it returns `optb`. /// Else, it returns `optb`.
/// ///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
///
/// # Examples /// # Examples
/// ///
/// Basic usage: /// Basic usage:
@ -686,8 +714,11 @@ impl<T, E> Result<T, E> {
} }
} }
/// Unwraps a result, yielding the content of an `Ok`. /// Unwraps a result, yielding the content of an [`Ok`].
/// If the value is an `Err` then it calls `op` with its value. /// If the value is an [`Err`] then it calls `op` with its value.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// ///
/// # Examples /// # Examples
/// ///
@ -710,12 +741,15 @@ impl<T, E> Result<T, E> {
} }
impl<T, E: fmt::Debug> Result<T, E> { impl<T, E: fmt::Debug> Result<T, E> {
/// Unwraps a result, yielding the content of an `Ok`. /// Unwraps a result, yielding the content of an [`Ok`].
/// ///
/// # Panics /// # Panics
/// ///
/// Panics if the value is an `Err`, with a panic message provided by the /// Panics if the value is an [`Err`], with a panic message provided by the
/// `Err`'s value. /// [`Err`]'s value.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// ///
/// # Examples /// # Examples
/// ///
@ -739,12 +773,15 @@ impl<T, E: fmt::Debug> Result<T, E> {
} }
} }
/// Unwraps a result, yielding the content of an `Ok`. /// Unwraps a result, yielding the content of an [`Ok`].
/// ///
/// # Panics /// # Panics
/// ///
/// Panics if the value is an `Err`, with a panic message including the /// Panics if the value is an [`Err`], with a panic message including the
/// passed message, and the content of the `Err`. /// passed message, and the content of the [`Err`].
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// ///
/// # Examples /// # Examples
/// ///
@ -765,12 +802,16 @@ impl<T, E: fmt::Debug> Result<T, E> {
} }
impl<T: fmt::Debug, E> Result<T, E> { impl<T: fmt::Debug, E> Result<T, E> {
/// Unwraps a result, yielding the content of an `Err`. /// Unwraps a result, yielding the content of an [`Err`].
/// ///
/// # Panics /// # Panics
/// ///
/// Panics if the value is an `Ok`, with a custom panic message provided /// Panics if the value is an [`Ok`], with a custom panic message provided
/// by the `Ok`'s value. /// by the [`Ok`]'s value.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
///
/// ///
/// # Examples /// # Examples
/// ///
@ -792,12 +833,15 @@ impl<T: fmt::Debug, E> Result<T, E> {
} }
} }
/// Unwraps a result, yielding the content of an `Err`. /// Unwraps a result, yielding the content of an [`Err`].
/// ///
/// # Panics /// # Panics
/// ///
/// Panics if the value is an `Ok`, with a panic message including the /// Panics if the value is an [`Ok`], with a panic message including the
/// passed message, and the content of the `Ok`. /// passed message, and the content of the [`Ok`].
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// ///
/// # Examples /// # Examples
/// ///
@ -820,8 +864,8 @@ impl<T: fmt::Debug, E> Result<T, E> {
impl<T: Default, E> Result<T, E> { impl<T: Default, E> Result<T, E> {
/// Returns the contained value or a default /// Returns the contained value or a default
/// ///
/// Consumes the `self` argument then, if `Ok`, returns the contained /// Consumes the `self` argument then, if [`Ok`], returns the contained
/// value, otherwise if `Err`, returns the default value for that /// value, otherwise if [`Err`], returns the default value for that
/// type. /// type.
/// ///
/// # Examples /// # Examples
@ -829,7 +873,7 @@ impl<T: Default, E> Result<T, E> {
/// Convert a string to an integer, turning poorly-formed strings /// Convert a string to an integer, turning poorly-formed strings
/// into 0 (the default value for integers). [`parse`] converts /// into 0 (the default value for integers). [`parse`] converts
/// a string to any other type that implements [`FromStr`], returning an /// a string to any other type that implements [`FromStr`], returning an
/// `Err` on error. /// [`Err`] on error.
/// ///
/// ``` /// ```
/// let good_year_from_input = "1909"; /// let good_year_from_input = "1909";
@ -843,6 +887,8 @@ impl<T: Default, E> Result<T, E> {
/// ///
/// [`parse`]: ../../std/primitive.str.html#method.parse /// [`parse`]: ../../std/primitive.str.html#method.parse
/// [`FromStr`]: ../../std/str/trait.FromStr.html /// [`FromStr`]: ../../std/str/trait.FromStr.html
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
#[inline] #[inline]
#[stable(feature = "result_unwrap_or_default", since = "1.16.0")] #[stable(feature = "result_unwrap_or_default", since = "1.16.0")]
pub fn unwrap_or_default(self) -> T { pub fn unwrap_or_default(self) -> T {