Skip to content

Commit 01d95f2

Browse files
committed
resolve comments
1 parent 8a92718 commit 01d95f2

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

library/core/src/convert/mod.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ pub const fn identity<T>(x: T) -> T {
134134
/// want to accept all references that can be converted to [`&str`] as an argument.
135135
/// Since both [`String`] and [`&str`] implement `AsRef<str>` we can accept both as input argument.
136136
///
137-
/// [`Option<T>`]: crate::option::Option
138-
/// [`Result<T, E>`]: crate::result::Result
137+
/// [`Option<T>`]: Option
138+
/// [`Result<T, E>`]: Result
139139
/// [`Borrow`]: crate::borrow::Borrow
140140
/// [`Eq`]: crate::cmp::Eq
141141
/// [`Ord`]: crate::cmp::Ord
@@ -168,8 +168,8 @@ pub trait AsRef<T: ?Sized> {
168168
/// **Note: This trait must not fail**. If the conversion can fail, use a
169169
/// dedicated method which returns an [`Option<T>`] or a [`Result<T, E>`].
170170
///
171-
/// [`Option<T>`]: crate::option::Option
172-
/// [`Result<T, E>`]: crate::result::Result
171+
/// [`Option<T>`]: Option
172+
/// [`Result<T, E>`]: Result
173173
///
174174
/// # Generic Implementations
175175
///
@@ -195,7 +195,7 @@ pub trait AsRef<T: ?Sized> {
195195
/// assert_eq!(*boxed_num, 1);
196196
/// ```
197197
///
198-
/// [`Box<T>`]: crate::boxed::Box<T>
198+
/// [`Box<T>`]: ../../std/boxed/struct.Box.html
199199
#[stable(feature = "rust1", since = "1.0.0")]
200200
pub trait AsMut<T: ?Sized> {
201201
/// Performs the conversion.
@@ -269,10 +269,10 @@ pub trait AsMut<T: ?Sized> {
269269
/// is_hello(s);
270270
/// ```
271271
///
272-
/// [`Option<T>`]: crate::option::Option
273-
/// [`Result<T, E>`]: crate::result::Result
272+
/// [`Option<T>`]: Option
273+
/// [`Result<T, E>`]: Result
274274
/// [`String`]: ../../std/string/struct.String.html
275-
/// [`Vec`]: crate::vec::Vec<T>
275+
/// [`Vec`]: ../../std/vec/struct.Vec.html
276276
#[stable(feature = "rust1", since = "1.0.0")]
277277
pub trait Into<T>: Sized {
278278
/// Performs the conversion.
@@ -358,9 +358,10 @@ pub trait Into<T>: Sized {
358358
/// }
359359
/// ```
360360
///
361-
/// [`Option<T>`]: crate::option::Option
362-
/// [`Result<T, E>`]: crate::result::Result
361+
/// [`Option<T>`]: Option
362+
/// [`Result<T, E>`]: Result
363363
/// [`String`]: ../../std/string/struct.String.html
364+
/// [`from`]: From::from
364365
/// [book]: ../../book/ch09-00-error-handling.html
365366
#[rustc_diagnostic_item = "from_trait"]
366367
#[stable(feature = "rust1", since = "1.0.0")]
@@ -418,7 +419,7 @@ pub trait TryInto<T>: Sized {
418419
/// # Generic Implementations
419420
///
420421
/// - `TryFrom<T> for U` implies [`TryInto`]`<U> for T`
421-
/// - [`TryFrom::try_from`] is reflexive, which means that `TryFrom<T> for T`
422+
/// - [`try_from`] is reflexive, which means that `TryFrom<T> for T`
422423
/// is implemented and cannot fail -- the associated `Error` type for
423424
/// calling `T::try_from()` on a value of type `T` is [`Infallible`].
424425
/// When the [`!`] type is stabilized [`Infallible`] and [`!`] will be
@@ -467,7 +468,7 @@ pub trait TryInto<T>: Sized {
467468
/// assert!(try_successful_smaller_number.is_ok());
468469
/// ```
469470
///
470-
/// [`i32::MAX`]: crate::i32::MAX
471+
/// [`try_from`]: TryFrom::try_from
471472
/// [`!`]: ../../std/primitive.never.html
472473
#[stable(feature = "try_from", since = "1.34.0")]
473474
pub trait TryFrom<T>: Sized {
@@ -670,8 +671,6 @@ impl AsRef<str> for str {
670671
/// the two `impl`s will start to overlap
671672
/// and therefore will be disallowed by the language’s trait coherence rules.
672673
///
673-
/// [`Ok`]: super::result::Result::Ok
674-
/// [`Result`]: super::result::Result
675674
/// [never]: ../../std/primitive.never.html
676675
#[stable(feature = "convert_infallible", since = "1.34.0")]
677676
#[derive(Copy)]

library/core/src/iter/mod.rs

+22-8
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,13 @@
152152
//! produce an iterator. What gives?
153153
//!
154154
//! There's a trait in the standard library for converting something into an
155-
//! iterator: [`IntoIterator`]. This trait has one method, [`IntoIterator::into_iter`],
155+
//! iterator: [`IntoIterator`]. This trait has one method, [`into_iter`],
156156
//! which converts the thing implementing [`IntoIterator`] into an iterator.
157157
//! Let's take a look at that `for` loop again, and what the compiler converts
158158
//! it into:
159159
//!
160+
//! [`into_iter`]: IntoIterator::into_iter
161+
//!
160162
//! ```
161163
//! let values = vec![1, 2, 3, 4, 5];
162164
//!
@@ -209,20 +211,24 @@
209211
//! often called 'iterator adapters', as they're a form of the 'adapter
210212
//! pattern'.
211213
//!
212-
//! Common iterator adapters include [`Iterator::map`], [`Iterator::take`], and [`Iterator::filter`].
214+
//! Common iterator adapters include [`map`], [`take`], and [`filter`].
213215
//! For more, see their documentation.
214216
//!
215217
//! If an iterator adapter panics, the iterator will be in an unspecified (but
216218
//! memory safe) state. This state is also not guaranteed to stay the same
217219
//! across versions of Rust, so you should avoid relying on the exact values
218220
//! returned by an iterator which panicked.
219221
//!
222+
//! [`map`]: Iterator::map
223+
//! [`take`]: Iterator::take
224+
//! [`filter`]: Iterator::filter
225+
//!
220226
//! # Laziness
221227
//!
222228
//! Iterators (and iterator [adapters](#adapters)) are *lazy*. This means that
223229
//! just creating an iterator doesn't _do_ a whole lot. Nothing really happens
224230
//! until you call [`next`]. This is sometimes a source of confusion when
225-
//! creating an iterator solely for its side effects. For example, the [`Iterator::map`]
231+
//! creating an iterator solely for its side effects. For example, the [`map`]
226232
//! method calls a closure on each element it iterates over:
227233
//!
228234
//! ```
@@ -239,8 +245,8 @@
239245
//! do nothing unless consumed
240246
//! ```
241247
//!
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:
248+
//! The idiomatic way to write a [`map`] for its side effects is to use a
249+
//! `for` loop or call the [`for_each`] method:
244250
//!
245251
//! ```
246252
//! let v = vec![1, 2, 3, 4, 5];
@@ -252,9 +258,14 @@
252258
//! }
253259
//! ```
254260
//!
255-
//! Another common way to evaluate an iterator is to use the [`Iterator::collect`]
261+
//! [`map`]: Iterator::map
262+
//! [`for_each`]: Iterator::for_each
263+
//!
264+
//! Another common way to evaluate an iterator is to use the [`collect`]
256265
//! method to produce a new collection.
257266
//!
267+
//! [`collect`]: Iterator::collect
268+
//!
258269
//! # Infinity
259270
//!
260271
//! Iterators do not have to be finite. As an example, an open-ended range is
@@ -264,7 +275,7 @@
264275
//! let numbers = 0..;
265276
//! ```
266277
//!
267-
//! It is common to use the [`Iterator::take`] iterator adapter to turn an infinite
278+
//! It is common to use the [`take`] iterator adapter to turn an infinite
268279
//! iterator into a finite one:
269280
//!
270281
//! ```
@@ -280,7 +291,7 @@
280291
//!
281292
//! Bear in mind that methods on infinite iterators, even those for which a
282293
//! result can be determined mathematically in finite time, may not terminate.
283-
//! Specifically, methods such as [`Iterator::min`], which in the general case require
294+
//! Specifically, methods such as [`min`], which in the general case require
284295
//! traversing every element in the iterator, are likely not to return
285296
//! successfully for any infinite iterators.
286297
//!
@@ -290,6 +301,9 @@
290301
//! // `ones.min()` causes an infinite loop, so we won't reach this point!
291302
//! println!("The smallest number one is {}.", least);
292303
//! ```
304+
//!
305+
//! [`take`]: Iterator::take
306+
//! [`min`]: Iterator::min
293307
294308
#![stable(feature = "rust1", since = "1.0.0")]
295309

0 commit comments

Comments
 (0)