31
31
//! `into` themselves and `from` themselves
32
32
//!
33
33
//! See each trait for usage examples.
34
- //!
35
- //! [`Into`]: trait.Into.html
36
- //! [`From`]: trait.From.html
37
- //! [`TryFrom`]: trait.TryFrom.html
38
- //! [`TryInto`]: trait.TryInto.html
39
- //! [`AsRef`]: trait.AsRef.html
40
- //! [`AsMut`]: trait.AsMut.html
41
34
42
35
#![ stable( feature = "rust1" , since = "1.0.0" ) ]
43
36
@@ -141,13 +134,11 @@ pub const fn identity<T>(x: T) -> T {
141
134
/// want to accept all references that can be converted to [`&str`] as an argument.
142
135
/// Since both [`String`] and [`&str`] implement `AsRef<str>` we can accept both as input argument.
143
136
///
144
- /// [`Option<T>`]: ../../std/option/enum.Option.html
145
- /// [`Result<T, E>`]: ../../std/result/enum.Result.html
146
- /// [`Borrow`]: ../../std/borrow/trait.Borrow.html
147
- /// [`Hash`]: ../../std/hash/trait.Hash.html
148
- /// [`Eq`]: ../../std/cmp/trait.Eq.html
149
- /// [`Ord`]: ../../std/cmp/trait.Ord.html
150
- /// [`&str`]: ../../std/primitive.str.html
137
+ /// [`Option<T>`]: Option
138
+ /// [`Result<T, E>`]: Result
139
+ /// [`Borrow`]: crate::borrow::Borrow
140
+ /// [`Eq`]: crate::cmp::Eq
141
+ /// [`Ord`]: crate::cmp::Ord
151
142
/// [`String`]: ../../std/string/struct.String.html
152
143
///
153
144
/// ```
@@ -177,8 +168,8 @@ pub trait AsRef<T: ?Sized> {
177
168
/// **Note: This trait must not fail**. If the conversion can fail, use a
178
169
/// dedicated method which returns an [`Option<T>`] or a [`Result<T, E>`].
179
170
///
180
- /// [`Option<T>`]: ../../std/option/enum. Option.html
181
- /// [`Result<T, E>`]: ../../std/result/enum. Result.html
171
+ /// [`Option<T>`]: Option
172
+ /// [`Result<T, E>`]: Result
182
173
///
183
174
/// # Generic Implementations
184
175
///
@@ -278,12 +269,9 @@ pub trait AsMut<T: ?Sized> {
278
269
/// is_hello(s);
279
270
/// ```
280
271
///
281
- /// [`TryInto`]: trait.TryInto.html
282
- /// [`Option<T>`]: ../../std/option/enum.Option.html
283
- /// [`Result<T, E>`]: ../../std/result/enum.Result.html
272
+ /// [`Option<T>`]: Option
273
+ /// [`Result<T, E>`]: Result
284
274
/// [`String`]: ../../std/string/struct.String.html
285
- /// [`From`]: trait.From.html
286
- /// [`Into`]: trait.Into.html
287
275
/// [`Vec`]: ../../std/vec/struct.Vec.html
288
276
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
289
277
pub trait Into < T > : Sized {
@@ -370,12 +358,10 @@ pub trait Into<T>: Sized {
370
358
/// }
371
359
/// ```
372
360
///
373
- /// [`TryFrom`]: trait.TryFrom.html
374
- /// [`Option<T>`]: ../../std/option/enum.Option.html
375
- /// [`Result<T, E>`]: ../../std/result/enum.Result.html
361
+ /// [`Option<T>`]: Option
362
+ /// [`Result<T, E>`]: Result
376
363
/// [`String`]: ../../std/string/struct.String.html
377
- /// [`Into`]: trait.Into.html
378
- /// [`from`]: trait.From.html#tymethod.from
364
+ /// [`from`]: From::from
379
365
/// [book]: ../../book/ch09-00-error-handling.html
380
366
#[ rustc_diagnostic_item = "from_trait" ]
381
367
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -404,9 +390,6 @@ pub trait From<T>: Sized {
404
390
///
405
391
/// This suffers the same restrictions and reasoning as implementing
406
392
/// [`Into`], see there for details.
407
- ///
408
- /// [`TryFrom`]: trait.TryFrom.html
409
- /// [`Into`]: trait.Into.html
410
393
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
411
394
pub trait TryInto < T > : Sized {
412
395
/// The type returned in the event of a conversion error.
@@ -485,11 +468,9 @@ pub trait TryInto<T>: Sized {
485
468
/// assert!(try_successful_smaller_number.is_ok());
486
469
/// ```
487
470
///
488
- /// [`try_from`]: trait.TryFrom.html#tymethod.try_from
489
- /// [`TryInto`]: trait.TryInto.html
490
- /// [`i32::MAX`]: ../../std/i32/constant.MAX.html
471
+ /// [`i32::MAX`]: crate::i32::MAX
472
+ /// [`try_from`]: TryFrom::try_from
491
473
/// [`!`]: ../../std/primitive.never.html
492
- /// [`Infallible`]: enum.Infallible.html
493
474
#[ stable( feature = "try_from" , since = "1.34.0" ) ]
494
475
pub trait TryFrom < T > : Sized {
495
476
/// The type returned in the event of a conversion error.
@@ -676,7 +657,6 @@ impl AsRef<str> for str {
676
657
///
677
658
/// … and eventually deprecate `Infallible`.
678
659
///
679
- ///
680
660
/// However there is one case where `!` syntax can be used
681
661
/// before `!` is stabilized as a full-fledged type: in the position of a function’s return type.
682
662
/// Specifically, it is possible implementations for two different function pointer types:
@@ -692,10 +672,6 @@ impl AsRef<str> for str {
692
672
/// the two `impl`s will start to overlap
693
673
/// and therefore will be disallowed by the language’s trait coherence rules.
694
674
///
695
- /// [`Ok`]: ../result/enum.Result.html#variant.Ok
696
- /// [`Result`]: ../result/enum.Result.html
697
- /// [`TryFrom`]: trait.TryFrom.html
698
- /// [`Into`]: trait.Into.html
699
675
/// [never]: ../../std/primitive.never.html
700
676
#[ stable( feature = "convert_infallible" , since = "1.34.0" ) ]
701
677
#[ derive( Copy ) ]
0 commit comments