Skip to content

Commit 8a92718

Browse files
committed
Switch to intra-doc links in core/src/{convert,iter}/mod.rs
1 parent 5c27700 commit 8a92718

File tree

2 files changed

+26
-67
lines changed

2 files changed

+26
-67
lines changed

library/core/src/convert/mod.rs

+17-41
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@
3131
//! `into` themselves and `from` themselves
3232
//!
3333
//! 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
4134
4235
#![stable(feature = "rust1", since = "1.0.0")]
4336

@@ -141,13 +134,11 @@ pub const fn identity<T>(x: T) -> T {
141134
/// want to accept all references that can be converted to [`&str`] as an argument.
142135
/// Since both [`String`] and [`&str`] implement `AsRef<str>` we can accept both as input argument.
143136
///
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>`]: crate::option::Option
138+
/// [`Result<T, E>`]: crate::result::Result
139+
/// [`Borrow`]: crate::borrow::Borrow
140+
/// [`Eq`]: crate::cmp::Eq
141+
/// [`Ord`]: crate::cmp::Ord
151142
/// [`String`]: ../../std/string/struct.String.html
152143
///
153144
/// ```
@@ -177,8 +168,8 @@ pub trait AsRef<T: ?Sized> {
177168
/// **Note: This trait must not fail**. If the conversion can fail, use a
178169
/// dedicated method which returns an [`Option<T>`] or a [`Result<T, E>`].
179170
///
180-
/// [`Option<T>`]: ../../std/option/enum.Option.html
181-
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
171+
/// [`Option<T>`]: crate::option::Option
172+
/// [`Result<T, E>`]: crate::result::Result
182173
///
183174
/// # Generic Implementations
184175
///
@@ -204,7 +195,7 @@ pub trait AsRef<T: ?Sized> {
204195
/// assert_eq!(*boxed_num, 1);
205196
/// ```
206197
///
207-
/// [`Box<T>`]: ../../std/boxed/struct.Box.html
198+
/// [`Box<T>`]: crate::boxed::Box<T>
208199
#[stable(feature = "rust1", since = "1.0.0")]
209200
pub trait AsMut<T: ?Sized> {
210201
/// Performs the conversion.
@@ -278,13 +269,10 @@ pub trait AsMut<T: ?Sized> {
278269
/// is_hello(s);
279270
/// ```
280271
///
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>`]: crate::option::Option
273+
/// [`Result<T, E>`]: crate::result::Result
284274
/// [`String`]: ../../std/string/struct.String.html
285-
/// [`From`]: trait.From.html
286-
/// [`Into`]: trait.Into.html
287-
/// [`Vec`]: ../../std/vec/struct.Vec.html
275+
/// [`Vec`]: crate::vec::Vec<T>
288276
#[stable(feature = "rust1", since = "1.0.0")]
289277
pub trait Into<T>: Sized {
290278
/// Performs the conversion.
@@ -370,12 +358,9 @@ pub trait Into<T>: Sized {
370358
/// }
371359
/// ```
372360
///
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>`]: crate::option::Option
362+
/// [`Result<T, E>`]: crate::result::Result
376363
/// [`String`]: ../../std/string/struct.String.html
377-
/// [`Into`]: trait.Into.html
378-
/// [`from`]: trait.From.html#tymethod.from
379364
/// [book]: ../../book/ch09-00-error-handling.html
380365
#[rustc_diagnostic_item = "from_trait"]
381366
#[stable(feature = "rust1", since = "1.0.0")]
@@ -404,9 +389,6 @@ pub trait From<T>: Sized {
404389
///
405390
/// This suffers the same restrictions and reasoning as implementing
406391
/// [`Into`], see there for details.
407-
///
408-
/// [`TryFrom`]: trait.TryFrom.html
409-
/// [`Into`]: trait.Into.html
410392
#[stable(feature = "try_from", since = "1.34.0")]
411393
pub trait TryInto<T>: Sized {
412394
/// The type returned in the event of a conversion error.
@@ -436,7 +418,7 @@ pub trait TryInto<T>: Sized {
436418
/// # Generic Implementations
437419
///
438420
/// - `TryFrom<T> for U` implies [`TryInto`]`<U> for T`
439-
/// - [`try_from`] is reflexive, which means that `TryFrom<T> for T`
421+
/// - [`TryFrom::try_from`] is reflexive, which means that `TryFrom<T> for T`
440422
/// is implemented and cannot fail -- the associated `Error` type for
441423
/// calling `T::try_from()` on a value of type `T` is [`Infallible`].
442424
/// When the [`!`] type is stabilized [`Infallible`] and [`!`] will be
@@ -485,11 +467,8 @@ pub trait TryInto<T>: Sized {
485467
/// assert!(try_successful_smaller_number.is_ok());
486468
/// ```
487469
///
488-
/// [`try_from`]: trait.TryFrom.html#tymethod.try_from
489-
/// [`TryInto`]: trait.TryInto.html
490-
/// [`i32::MAX`]: ../../std/i32/constant.MAX.html
470+
/// [`i32::MAX`]: crate::i32::MAX
491471
/// [`!`]: ../../std/primitive.never.html
492-
/// [`Infallible`]: enum.Infallible.html
493472
#[stable(feature = "try_from", since = "1.34.0")]
494473
pub trait TryFrom<T>: Sized {
495474
/// The type returned in the event of a conversion error.
@@ -676,7 +655,6 @@ impl AsRef<str> for str {
676655
///
677656
/// … and eventually deprecate `Infallible`.
678657
///
679-
///
680658
/// However there is one case where `!` syntax can be used
681659
/// before `!` is stabilized as a full-fledged type: in the position of a function’s return type.
682660
/// Specifically, it is possible implementations for two different function pointer types:
@@ -692,10 +670,8 @@ impl AsRef<str> for str {
692670
/// the two `impl`s will start to overlap
693671
/// and therefore will be disallowed by the language’s trait coherence rules.
694672
///
695-
/// [`Ok`]: ../result/enum.Result.html#variant.Ok
696-
/// [`Result`]: ../result/enum.Result.html
697-
/// [`TryFrom`]: trait.TryFrom.html
698-
/// [`Into`]: trait.Into.html
673+
/// [`Ok`]: super::result::Result::Ok
674+
/// [`Result`]: super::result::Result
699675
/// [never]: ../../std/primitive.never.html
700676
#[stable(feature = "convert_infallible", since = "1.34.0")]
701677
#[derive(Copy)]

library/core/src/iter/mod.rs

+9-26
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@
5353
//! more complex forms of processing. See the [Adapters](#adapters) section
5454
//! below for more details.
5555
//!
56-
//! [`Some(Item)`]: Some
57-
//! [`Iterator`]: trait.Iterator.html
58-
//! [`next`]: trait.Iterator.html#tymethod.next
56+
//! [`next`]: Iterator::next
5957
//! [`TryIter`]: ../../std/sync/mpsc/struct.TryIter.html
6058
//!
6159
//! # The three forms of iteration
@@ -154,14 +152,11 @@
154152
//! produce an iterator. What gives?
155153
//!
156154
//! There's a trait in the standard library for converting something into an
157-
//! iterator: [`IntoIterator`]. This trait has one method, [`into_iter`],
155+
//! iterator: [`IntoIterator`]. This trait has one method, [`IntoIterator::into_iter`],
158156
//! which converts the thing implementing [`IntoIterator`] into an iterator.
159157
//! Let's take a look at that `for` loop again, and what the compiler converts
160158
//! it into:
161159
//!
162-
//! [`IntoIterator`]: trait.IntoIterator.html
163-
//! [`into_iter`]: trait.IntoIterator.html#tymethod.into_iter
164-
//!
165160
//! ```
166161
//! let values = vec![1, 2, 3, 4, 5];
167162
//!
@@ -214,24 +209,20 @@
214209
//! often called 'iterator adapters', as they're a form of the 'adapter
215210
//! pattern'.
216211
//!
217-
//! Common iterator adapters include [`map`], [`take`], and [`filter`].
212+
//! Common iterator adapters include [`Iterator::map`], [`Iterator::take`], and [`Iterator::filter`].
218213
//! For more, see their documentation.
219214
//!
220215
//! If an iterator adapter panics, the iterator will be in an unspecified (but
221216
//! memory safe) state. This state is also not guaranteed to stay the same
222217
//! across versions of Rust, so you should avoid relying on the exact values
223218
//! returned by an iterator which panicked.
224219
//!
225-
//! [`map`]: trait.Iterator.html#method.map
226-
//! [`take`]: trait.Iterator.html#method.take
227-
//! [`filter`]: trait.Iterator.html#method.filter
228-
//!
229220
//! # Laziness
230221
//!
231222
//! Iterators (and iterator [adapters](#adapters)) are *lazy*. This means that
232223
//! just creating an iterator doesn't _do_ a whole lot. Nothing really happens
233224
//! until you call [`next`]. This is sometimes a source of confusion when
234-
//! creating an iterator solely for its side effects. For example, the [`map`]
225+
//! creating an iterator solely for its side effects. For example, the [`Iterator::map`]
235226
//! method calls a closure on each element it iterates over:
236227
//!
237228
//! ```
@@ -248,8 +239,8 @@
248239
//! do nothing unless consumed
249240
//! ```
250241
//!
251-
//! The idiomatic way to write a [`map`] for its side effects is to use a
252-
//! `for` loop or call the [`for_each`] method:
242+
//! The idiomatic way to write a [`Iterator::map`] for its side effects is to use a
243+
//! `for` loop or call the [`Iterator::for_each`] method:
253244
//!
254245
//! ```
255246
//! let v = vec![1, 2, 3, 4, 5];
@@ -261,14 +252,9 @@
261252
//! }
262253
//! ```
263254
//!
264-
//! [`map`]: trait.Iterator.html#method.map
265-
//! [`for_each`]: trait.Iterator.html#method.for_each
266-
//!
267-
//! Another common way to evaluate an iterator is to use the [`collect`]
255+
//! Another common way to evaluate an iterator is to use the [`Iterator::collect`]
268256
//! method to produce a new collection.
269257
//!
270-
//! [`collect`]: trait.Iterator.html#method.collect
271-
//!
272258
//! # Infinity
273259
//!
274260
//! Iterators do not have to be finite. As an example, an open-ended range is
@@ -278,7 +264,7 @@
278264
//! let numbers = 0..;
279265
//! ```
280266
//!
281-
//! It is common to use the [`take`] iterator adapter to turn an infinite
267+
//! It is common to use the [`Iterator::take`] iterator adapter to turn an infinite
282268
//! iterator into a finite one:
283269
//!
284270
//! ```
@@ -294,7 +280,7 @@
294280
//!
295281
//! Bear in mind that methods on infinite iterators, even those for which a
296282
//! result can be determined mathematically in finite time, may not terminate.
297-
//! Specifically, methods such as [`min`], which in the general case require
283+
//! Specifically, methods such as [`Iterator::min`], which in the general case require
298284
//! traversing every element in the iterator, are likely not to return
299285
//! successfully for any infinite iterators.
300286
//!
@@ -304,9 +290,6 @@
304290
//! // `ones.min()` causes an infinite loop, so we won't reach this point!
305291
//! println!("The smallest number one is {}.", least);
306292
//! ```
307-
//!
308-
//! [`take`]: trait.Iterator.html#method.take
309-
//! [`min`]: trait.Iterator.html#method.min
310293
311294
#![stable(feature = "rust1", since = "1.0.0")]
312295

0 commit comments

Comments
 (0)