Skip to content

Commit 0ba3324

Browse files
committed
Re-link documentation where possible in alloc::io
Items in the prelude can't have hardcoded links, as they are either correct in the prelude or in their original location, not both.
1 parent 7fb742b commit 0ba3324

5 files changed

Lines changed: 21 additions & 12 deletions

File tree

library/alloc/src/io/buf_read.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::io::{ErrorKind, Lines, Read, Result, Split, append_to_string, lines,
44
use crate::string::String;
55
use crate::vec::Vec;
66

7-
/// A `BufRead` is a type of `Read`er which has an internal buffer, allowing it
7+
/// A `BufRead` is a type of [`Read`]er which has an internal buffer, allowing it
88
/// to perform extra ways of reading.
99
///
1010
/// For example, reading line-by-line is inefficient without using a buffer, so
@@ -55,7 +55,7 @@ use crate::vec::Vec;
5555
#[stable(feature = "rust1", since = "1.0.0")]
5656
#[cfg_attr(not(test), rustc_diagnostic_item = "IoBufRead")]
5757
pub trait BufRead: Read {
58-
/// Returns the contents of the internal buffer, filling it with more data, via `Read` methods, if empty.
58+
/// Returns the contents of the internal buffer, filling it with more data, via [`Read`] methods, if empty.
5959
///
6060
/// This is a lower-level method and is meant to be used together with [`consume`],
6161
/// which can be used to mark bytes that should not be returned by subsequent calls to `read`.
@@ -66,7 +66,7 @@ pub trait BufRead: Read {
6666
///
6767
/// # Errors
6868
///
69-
/// This function will return an I/O error if a `Read` method was called, but returned an error.
69+
/// This function will return an I/O error if a [`Read`] method was called, but returned an error.
7070
///
7171
/// # Examples
7272
///
@@ -96,7 +96,7 @@ pub trait BufRead: Read {
9696
/// Subsequent calls to `read` only return bytes that have not been marked as read.
9797
///
9898
/// This is a lower-level method and is meant to be used together with [`fill_buf`],
99-
/// which can be used to fill the internal buffer via `Read` methods.
99+
/// which can be used to fill the internal buffer via [`Read`] methods.
100100
///
101101
/// It is a logic error if `amount` exceeds the number of unread bytes in the internal buffer, which is returned by [`fill_buf`].
102102
///
@@ -120,7 +120,7 @@ pub trait BufRead: Read {
120120
///
121121
/// # Errors
122122
///
123-
/// This function will return an I/O error if a `Read` method was called, but returned an error.
123+
/// This function will return an I/O error if a [`Read`] method was called, but returned an error.
124124
///
125125
/// Examples
126126
///
@@ -274,7 +274,7 @@ pub trait BufRead: Read {
274274
}
275275

276276
/// Reads all bytes until a newline (the `0xA` byte) is reached, and append
277-
/// them to the provided `String` buffer.
277+
/// them to the provided [`String`] buffer.
278278
///
279279
/// Previous content of the buffer will be preserved. To avoid appending to
280280
/// the buffer, you need to [`clear`] it first.

library/alloc/src/io/buffered/bufreader.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use crate::vec::Vec;
1919
/// results in a system call. A `BufReader<R>` performs large, infrequent reads on
2020
/// the underlying [`Read`] and maintains an in-memory buffer of the results.
2121
///
22+
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html
23+
///
2224
/// `BufReader<R>` can improve the speed of programs that make *small* and
2325
/// *repeated* read calls to the same file or network socket. It does not
2426
/// help when reading very large amounts at once, or reading just one or a few

library/alloc/src/io/buffered/bufwriter.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ use crate::vec::Vec;
2828
///
2929
/// # Examples
3030
///
31-
/// Let's write the numbers one through ten to a `TcpStream`:
31+
/// Let's write the numbers one through ten to a [`TcpStream`]:
32+
///
33+
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html
3234
///
3335
/// ```no_run
3436
/// use std::io::prelude::*;

library/alloc/src/io/read.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ use crate::vec::Vec;
2222
/// trait.
2323
///
2424
/// Please note that each call to [`read()`] may involve a system call, and
25-
/// therefore, using something that implements `BufRead`, such as
26-
/// `BufReader`, will be more efficient.
25+
/// therefore, using something that implements [`BufRead`], such as
26+
/// [`BufReader`], will be more efficient.
27+
///
28+
/// [`BufRead`]: crate::io::BufRead
29+
/// [`BufReader`]: crate::io::BufReader
2730
///
2831
/// Repeated calls to the reader use the same cursor, so for example
2932
/// calling `read_to_end` twice on a `File` will only return the file's
@@ -480,7 +483,9 @@ pub trait Read {
480483
///
481484
/// The default implementation calls `read` for each byte,
482485
/// which can be very inefficient for data that's not in memory,
483-
/// such as `File`. Consider using a `BufReader` in such cases.
486+
/// such as `File`. Consider using a [`BufReader`] in such cases.
487+
///
488+
/// [`BufReader`]: crate::io::BufReader
484489
///
485490
/// # Examples
486491
///

library/alloc/src/io/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,9 @@ pub const fn split<B>(buf: B, delim: u8) -> Split<B> {
440440
Split { buf, delim }
441441
}
442442

443-
/// An iterator over the lines of an instance of `BufRead`.
443+
/// An iterator over the lines of an instance of [`BufRead`].
444444
///
445-
/// This struct is generally created by calling [`lines`] on a `BufRead`.
445+
/// This struct is generally created by calling [`lines`] on a [`BufRead`].
446446
/// Please see the documentation of [`lines`] for more details.
447447
///
448448
/// [`lines`]: BufRead::lines

0 commit comments

Comments
 (0)