From eba03d462e987a969d21aa74632e4d96dbe9751e Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Fri, 12 Apr 2019 01:23:23 -0500 Subject: [PATCH 1/7] Fix convert module's documentation links --- src/libcore/convert.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index e903bd936c484..dbe0d204aca8d 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -213,7 +213,7 @@ pub trait AsMut { /// /// # Generic Implementations /// -/// - [`From`]` for U` implies `Into for T` +/// - [`From`]` for U` implies `Into for T` /// - [`Into`]` is reflexive, which means that `Into for T` is implemented /// /// # Implementing `Into` for conversions to external types @@ -273,7 +273,7 @@ pub trait AsMut { /// [`Option`]: ../../std/option/enum.Option.html /// [`Result`]: ../../std/result/enum.Result.html /// [`String`]: ../../std/string/struct.String.html -/// [From]: trait.From.html +/// [`From`]: trait.From.html /// [`into`]: trait.Into.html#tymethod.into #[stable(feature = "rust1", since = "1.0.0")] pub trait Into: Sized { @@ -285,18 +285,18 @@ pub trait Into: Sized { /// Used to do value-to-value conversions while consuming the input value. It is the reciprocal of /// [`Into`]. /// -/// One should always prefer implementing [`From`] over [`Into`] -/// because implementing [`From`] automatically provides one with a implementation of [`Into`] +/// One should always prefer implementing `From` over [`Into`] +/// because implementing `From` automatically provides one with a implementation of [`Into`] /// thanks to the blanket implementation in the standard library. /// /// Only implement [`Into`] if a conversion to a type outside the current crate is required. -/// [`From`] cannot do these type of conversions because of Rust's orphaning rules. +/// `From` cannot do these type of conversions because of Rust's orphaning rules. /// See [`Into`] for more details. /// -/// Prefer using [`Into`] over using [`From`] when specifying trait bounds on a generic function. +/// Prefer using [`Into`] over using `From` when specifying trait bounds on a generic function. /// This way, types that directly implement [`Into`] can be used as arguments as well. /// -/// The [`From`] is also very useful when performing error handling. When constructing a function +/// The `From` is also very useful when performing error handling. When constructing a function /// that is capable of failing, the return type will generally be of the form `Result`. /// The `From` trait simplifies error handling by allowing a function to return a single error type /// that encapsulate multiple error types. See the "Examples" section and [the book][book] for more @@ -306,8 +306,8 @@ pub trait Into: Sized { /// /// # Generic Implementations /// -/// - [`From`]` for U` implies [`Into`]` for T` -/// - [`From`] is reflexive, which means that `From for T` is implemented +/// - `From` for U` implies [`Into`]` for T` +/// - `From` is reflexive, which means that `From for T` is implemented /// /// # Examples /// @@ -361,7 +361,7 @@ pub trait Into: Sized { /// [`Option`]: ../../std/option/enum.Option.html /// [`Result`]: ../../std/result/enum.Result.html /// [`String`]: ../../std/string/struct.String.html -/// [`Into`]: trait.Into.html +/// [`Into`]: trait.Into.html /// [`from`]: trait.From.html#tymethod.from /// [book]: ../../book/ch09-00-error-handling.html #[stable(feature = "rust1", since = "1.0.0")] @@ -422,7 +422,7 @@ pub trait TryInto: Sized { /// /// # Generic Implementations /// -/// - `TryFrom for U` implies [`TryInto`]` for T` +/// - `TryFrom for U` implies [`TryInto`]` for T` /// - [`try_from`] is reflexive, which means that `TryFrom for T` /// is implemented and cannot fail -- the associated `Error` type for /// calling `T::try_from()` on a value of type `T` is `Infallible`. From 6bf94cd3ff4af69c8128fb64d28a60f6c9385c19 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Sat, 13 Apr 2019 10:34:42 -0500 Subject: [PATCH 2/7] Remove dangling ` in Into documentation --- src/libcore/convert.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index dbe0d204aca8d..e981001bd6415 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -214,7 +214,7 @@ pub trait AsMut { /// # Generic Implementations /// /// - [`From`]` for U` implies `Into for T` -/// - [`Into`]` is reflexive, which means that `Into for T` is implemented +/// - [`Into`] is reflexive, which means that `Into for T` is implemented /// /// # Implementing `Into` for conversions to external types /// From b701d32ca80e58d41cadc18755567794d5e65bd9 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Sat, 13 Apr 2019 10:38:06 -0500 Subject: [PATCH 3/7] Remove broken links to self in Into documentation --- src/libcore/convert.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index e981001bd6415..2498159edc708 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -203,9 +203,9 @@ pub trait AsMut { /// A value-to-value conversion that consumes the input value. The /// opposite of [`From`]. /// -/// One should only implement [`Into`] if a conversion to a type outside the current crate is -/// required. Otherwise one should always prefer implementing [`From`] over [`Into`] because -/// implementing [`From`] automatically provides one with a implementation of [`Into`] thanks to +/// One should only implement `Into` if a conversion to a type outside the current crate is +/// required. Otherwise one should always prefer implementing [`From`] over `Into` because +/// implementing [`From`] automatically provides one with a implementation of `Into` thanks to /// the blanket implementation in the standard library. [`From`] cannot do these type of /// conversions because of Rust's orphaning rules. /// @@ -214,7 +214,7 @@ pub trait AsMut { /// # Generic Implementations /// /// - [`From`]` for U` implies `Into for T` -/// - [`Into`] is reflexive, which means that `Into for T` is implemented +/// - `Into` is reflexive, which means that `Into for T` is implemented /// /// # Implementing `Into` for conversions to external types /// From 4a33ece38216a42764a0c74ae99baf183b888817 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Sat, 13 Apr 2019 11:57:02 -0500 Subject: [PATCH 4/7] Remove blank lines in AsRef documentation --- src/libcore/convert.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 2498159edc708..e04c01e50c0bc 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -104,7 +104,6 @@ pub const fn identity(x: T) -> T { x } /// If you need to do a costly conversion it is better to implement [`From`] with type /// `&T` or write a custom function. /// -/// /// `AsRef` has the same signature as [`Borrow`], but `Borrow` is different in few aspects: /// /// - Unlike `AsRef`, `Borrow` has a blanket impl for any `T`, and can be used to accept either @@ -149,7 +148,6 @@ pub const fn identity(x: T) -> T { x } /// let s = "hello".to_string(); /// is_hello(s); /// ``` -/// #[stable(feature = "rust1", since = "1.0.0")] pub trait AsRef { /// Performs the conversion. From 27ff5360ab661a3c20ab7256529aeb61b4e2b215 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Sat, 13 Apr 2019 15:25:13 -0500 Subject: [PATCH 5/7] Reorder blank lines in AsMut documentation --- src/libcore/convert.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index e04c01e50c0bc..86846d3842c08 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -180,6 +180,7 @@ pub trait AsRef { /// write a function `add_one`that takes all arguments that can be converted to `&mut u64`. /// Because [`Box`] implements `AsMut` `add_one` accepts arguments of type /// `&mut Box` as well: +/// /// ``` /// fn add_one>(num: &mut T) { /// *num.as_mut() += 1; @@ -189,8 +190,8 @@ pub trait AsRef { /// add_one(&mut boxed_num); /// assert_eq!(*boxed_num, 1); /// ``` -/// [`Box`]: ../../std/boxed/struct.Box.html /// +/// [`Box`]: ../../std/boxed/struct.Box.html #[stable(feature = "rust1", since = "1.0.0")] pub trait AsMut { /// Performs the conversion. From 1e48da6c81ba407b83189adff90abbd224dc1b62 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Sat, 13 Apr 2019 18:14:44 -0500 Subject: [PATCH 6/7] Escape &str in convert docs --- src/libcore/convert.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 86846d3842c08..df178e0ff0a61 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -132,7 +132,7 @@ pub const fn identity(x: T) -> T { x } /// converted a the specified type `T`. /// /// For example: By creating a generic function that takes an `AsRef` we express that we -/// want to accept all references that can be converted to &str as an argument. +/// want to accept all references that can be converted to `&str` as an argument. /// Since both [`String`] and `&str` implement `AsRef` we can accept both as input argument. /// /// [`String`]: ../../std/string/struct.String.html @@ -312,7 +312,8 @@ pub trait Into: Sized { /// /// [`String`] implements `From<&str>`: /// -/// An explicit conversion from a &str to a String is done as follows: +/// An explicit conversion from a `&str` to a String is done as follows: +/// /// ``` /// let string = "hello".to_string(); /// let other_string = String::from("hello"); From 1f5d510604be553906cdcbb2eddaf5277faf543d Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Sat, 13 Apr 2019 21:23:31 -0500 Subject: [PATCH 7/7] Fix stray ` in previous change --- src/libcore/convert.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index df178e0ff0a61..9da1c02dea065 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -305,7 +305,7 @@ pub trait Into: Sized { /// /// # Generic Implementations /// -/// - `From` for U` implies [`Into`]` for T` +/// - `From for U` implies [`Into`]` for T` /// - `From` is reflexive, which means that `From for T` is implemented /// /// # Examples