@@ -104,7 +104,6 @@ pub const fn identity<T>(x: T) -> T { x }
104104/// If you need to do a costly conversion it is better to implement [`From`] with type
105105/// `&T` or write a custom function.
106106///
107- ///
108107/// `AsRef` has the same signature as [`Borrow`], but `Borrow` is different in few aspects:
109108///
110109/// - Unlike `AsRef`, `Borrow` has a blanket impl for any `T`, and can be used to accept either
@@ -133,7 +132,7 @@ pub const fn identity<T>(x: T) -> T { x }
133132/// converted a the specified type `T`.
134133///
135134/// For example: By creating a generic function that takes an `AsRef<str>` we express that we
136- /// want to accept all references that can be converted to &str as an argument.
135+ /// want to accept all references that can be converted to ` &str` as an argument.
137136/// Since both [`String`] and `&str` implement `AsRef<str>` we can accept both as input argument.
138137///
139138/// [`String`]: ../../std/string/struct.String.html
@@ -149,7 +148,6 @@ pub const fn identity<T>(x: T) -> T { x }
149148/// let s = "hello".to_string();
150149/// is_hello(s);
151150/// ```
152- ///
153151#[ stable( feature = "rust1" , since = "1.0.0" ) ]
154152pub trait AsRef < T : ?Sized > {
155153 /// Performs the conversion.
@@ -182,6 +180,7 @@ pub trait AsRef<T: ?Sized> {
182180/// write a function `add_one`that takes all arguments that can be converted to `&mut u64`.
183181/// Because [`Box<T>`] implements `AsMut<T>` `add_one` accepts arguments of type
184182/// `&mut Box<u64>` as well:
183+ ///
185184/// ```
186185/// fn add_one<T: AsMut<u64>>(num: &mut T) {
187186/// *num.as_mut() += 1;
@@ -191,8 +190,8 @@ pub trait AsRef<T: ?Sized> {
191190/// add_one(&mut boxed_num);
192191/// assert_eq!(*boxed_num, 1);
193192/// ```
194- /// [`Box<T>`]: ../../std/boxed/struct.Box.html
195193///
194+ /// [`Box<T>`]: ../../std/boxed/struct.Box.html
196195#[ stable( feature = "rust1" , since = "1.0.0" ) ]
197196pub trait AsMut < T : ?Sized > {
198197 /// Performs the conversion.
@@ -203,18 +202,18 @@ pub trait AsMut<T: ?Sized> {
203202/// A value-to-value conversion that consumes the input value. The
204203/// opposite of [`From`].
205204///
206- /// One should only implement [ `Into`] if a conversion to a type outside the current crate is
207- /// required. Otherwise one should always prefer implementing [`From`] over [ `Into`] because
208- /// implementing [`From`] automatically provides one with a implementation of [ `Into`] thanks to
205+ /// One should only implement `Into` if a conversion to a type outside the current crate is
206+ /// required. Otherwise one should always prefer implementing [`From`] over `Into` because
207+ /// implementing [`From`] automatically provides one with a implementation of `Into` thanks to
209208/// the blanket implementation in the standard library. [`From`] cannot do these type of
210209/// conversions because of Rust's orphaning rules.
211210///
212211/// **Note: This trait must not fail**. If the conversion can fail, use [`TryInto`].
213212///
214213/// # Generic Implementations
215214///
216- /// - [`From<T> `]` for U` implies `Into<U> for T`
217- /// - [ `Into`] ` is reflexive, which means that `Into<T> for T` is implemented
215+ /// - [`From`]`<T> for U` implies `Into<U> for T`
216+ /// - `Into` is reflexive, which means that `Into<T> for T` is implemented
218217///
219218/// # Implementing `Into` for conversions to external types
220219///
@@ -273,7 +272,7 @@ pub trait AsMut<T: ?Sized> {
273272/// [`Option<T>`]: ../../std/option/enum.Option.html
274273/// [`Result<T, E>`]: ../../std/result/enum.Result.html
275274/// [`String`]: ../../std/string/struct.String.html
276- /// [From]: trait.From.html
275+ /// [` From` ]: trait.From.html
277276/// [`into`]: trait.Into.html#tymethod.into
278277#[ stable( feature = "rust1" , since = "1.0.0" ) ]
279278pub trait Into < T > : Sized {
@@ -285,18 +284,18 @@ pub trait Into<T>: Sized {
285284/// Used to do value-to-value conversions while consuming the input value. It is the reciprocal of
286285/// [`Into`].
287286///
288- /// One should always prefer implementing [ `From`] over [`Into`]
289- /// because implementing [ `From`] automatically provides one with a implementation of [`Into`]
287+ /// One should always prefer implementing `From` over [`Into`]
288+ /// because implementing `From` automatically provides one with a implementation of [`Into`]
290289/// thanks to the blanket implementation in the standard library.
291290///
292291/// Only implement [`Into`] if a conversion to a type outside the current crate is required.
293- /// [ `From`] cannot do these type of conversions because of Rust's orphaning rules.
292+ /// `From` cannot do these type of conversions because of Rust's orphaning rules.
294293/// See [`Into`] for more details.
295294///
296- /// Prefer using [`Into`] over using [ `From`] when specifying trait bounds on a generic function.
295+ /// Prefer using [`Into`] over using `From` when specifying trait bounds on a generic function.
297296/// This way, types that directly implement [`Into`] can be used as arguments as well.
298297///
299- /// The [ `From`] is also very useful when performing error handling. When constructing a function
298+ /// The `From` is also very useful when performing error handling. When constructing a function
300299/// that is capable of failing, the return type will generally be of the form `Result<T, E>`.
301300/// The `From` trait simplifies error handling by allowing a function to return a single error type
302301/// that encapsulate multiple error types. See the "Examples" section and [the book][book] for more
@@ -306,14 +305,15 @@ pub trait Into<T>: Sized {
306305///
307306/// # Generic Implementations
308307///
309- /// - [ `From<T>`]` for U` implies [`Into<U> `]` for T`
310- /// - [ `From`] is reflexive, which means that `From<T> for T` is implemented
308+ /// - `From<T> for U` implies [`Into`]`<U> for T`
309+ /// - `From` is reflexive, which means that `From<T> for T` is implemented
311310///
312311/// # Examples
313312///
314313/// [`String`] implements `From<&str>`:
315314///
316- /// An explicit conversion from a &str to a String is done as follows:
315+ /// An explicit conversion from a `&str` to a String is done as follows:
316+ ///
317317/// ```
318318/// let string = "hello".to_string();
319319/// let other_string = String::from("hello");
@@ -361,7 +361,7 @@ pub trait Into<T>: Sized {
361361/// [`Option<T>`]: ../../std/option/enum.Option.html
362362/// [`Result<T, E>`]: ../../std/result/enum.Result.html
363363/// [`String`]: ../../std/string/struct.String.html
364- /// [`Into<U> `]: trait.Into.html
364+ /// [`Into`]: trait.Into.html
365365/// [`from`]: trait.From.html#tymethod.from
366366/// [book]: ../../book/ch09-00-error-handling.html
367367#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -422,7 +422,7 @@ pub trait TryInto<T>: Sized {
422422///
423423/// # Generic Implementations
424424///
425- /// - `TryFrom<T> for U` implies [`TryInto<U> `]` for T`
425+ /// - `TryFrom<T> for U` implies [`TryInto`]`<U> for T`
426426/// - [`try_from`] is reflexive, which means that `TryFrom<T> for T`
427427/// is implemented and cannot fail -- the associated `Error` type for
428428/// calling `T::try_from()` on a value of type `T` is `Infallible`.
0 commit comments