about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSimon Heath <icefox@dreamquest.io>2019-02-13 12:52:35 -0500
committerSimon Sapin <simon.sapin@exyr.org>2019-02-27 16:03:11 +0100
commitcc6f394d6f1ea4f452a944685d422125a5f71ac3 (patch)
tree6d1d4410e4d434d1c712e78c3cf6c30d89c51e97
parentc1d1c6731c22a2840eecd72b9bfb4ffc6f05647b (diff)
downloadrust-cc6f394d6f1ea4f452a944685d422125a5f71ac3.tar.gz
rust-cc6f394d6f1ea4f452a944685d422125a5f71ac3.zip
Fix some links in TryFrom docs.
-rw-r--r--src/libcore/convert.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs
index f64f2fb3e9f..4716aea1cdd 100644
--- a/src/libcore/convert.rs
+++ b/src/libcore/convert.rs
@@ -361,11 +361,12 @@ pub trait From<T>: Sized {
 /// An attempted conversion that consumes `self`, which may or may not be
 /// expensive.
 ///
-/// Library authors should not directly implement this trait, but should prefer
-/// implementing the [`TryFrom`] trait, which offers greater flexibility and
-/// provides an equivalent `TryInto` implementation for free, thanks to a
-/// blanket implementation in the standard library. For more information on this,
-/// see the documentation for [`Into`].
+/// Library authors should usually not directly implement this trait,
+/// but should prefer implementing the [`TryFrom`] trait, which offers
+/// greater flexibility and provides an equivalent `TryInto`
+/// implementation for free, thanks to a blanket implementation in the
+/// standard library. For more information on this, see the
+/// documentation for [`Into`].
 ///
 /// # Implementing `TryInto`
 ///
@@ -396,7 +397,7 @@ pub trait TryInto<T>: Sized {
 /// This might be handled by truncating the `i64` to an `i32` (essentially
 /// giving the `i64`'s value modulo `i32::MAX`) or by simply returning
 /// `i32::MAX`, or by some other method.  The `From` trait is intended
-/// for lossless conversions, so the `TryFrom` trait informs the
+/// for perfect conversions, so the `TryFrom` trait informs the
 /// programmer when a type conversion could go bad and lets them
 /// decide how to handle it.
 ///
@@ -404,7 +405,8 @@ pub trait TryInto<T>: Sized {
 ///
 /// - `TryFrom<T> for U` implies [`TryInto<U>`]` for T`
 /// - [`try_from`] is reflexive, which means that `TryFrom<T> for T`
-/// is implemented
+/// is implemented and cannot fail -- the associated `Error` type for
+/// calling `T::try_from()` on a value of type `T` is `!`.
 ///
 /// # Examples
 ///
@@ -417,12 +419,18 @@ pub trait TryInto<T>: Sized {
 /// let smaller_number = big_number as i32;
 /// assert_eq!(smaller_number, -727379968);
 ///
+/// // Returns an error because `big_number` is too big to
+/// // fit in an `i32`.
 /// let try_smaller_number = i32::try_from(big_number);
 /// assert!(try_smaller_number.is_err());
 ///
+/// // Returns `Ok(3)`.
 /// let try_successful_smaller_number = i32::try_from(3);
 /// assert!(try_successful_smaller_number.is_ok());
 /// ```
+///
+/// [`try_from`]: trait.TryFrom.html#tymethod.try_from
+/// [`TryInto`]: trait.TryInto.html
 #[stable(feature = "try_from", since = "1.34.0")]
 pub trait TryFrom<T>: Sized {
     /// The type returned in the event of a conversion error.