Skip to content

Commit 26ba0e1

Browse files
committed
Use intra-doc links in std::io
1 parent 4c48ac3 commit 26ba0e1

File tree

1 file changed

+51
-90
lines changed

1 file changed

+51
-90
lines changed

src/libstd/io/mod.rs

Lines changed: 51 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -238,25 +238,14 @@
238238
//! contract. The implementation of many of these functions are subject to change over
239239
//! time and may call fewer or more syscalls/library functions.
240240
//!
241-
//! [`Read`]: trait.Read.html
242-
//! [`Write`]: trait.Write.html
243-
//! [`Seek`]: trait.Seek.html
244-
//! [`BufRead`]: trait.BufRead.html
245-
//! [`File`]: ../fs/struct.File.html
246-
//! [`TcpStream`]: ../net/struct.TcpStream.html
247-
//! [`Vec<T>`]: ../vec/struct.Vec.html
248-
//! [`BufReader`]: struct.BufReader.html
249-
//! [`BufWriter`]: struct.BufWriter.html
250-
//! [`Write::write`]: trait.Write.html#tymethod.write
251-
//! [`io::stdout`]: fn.stdout.html
252-
//! [`println!`]: ../macro.println.html
253-
//! [`Lines`]: struct.Lines.html
254-
//! [`io::Result`]: type.Result.html
241+
//! [`File`]: crate::fs::File
242+
//! [`TcpStream`]: crate::net::TcpStream
243+
//! [`Vec<T>`]: crate::vec::Vec
244+
//! [`io::stdout`]: stdout
245+
//! [`io::Result`]: crate::io::Result
255246
//! [`?` operator]: ../../book/appendix-02-operators.html
256-
//! [`Read::read`]: trait.Read.html#tymethod.read
257-
//! [`Result`]: ../result/enum.Result.html
258-
//! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap
259-
// ignore-tidy-filelength
247+
//! [`Result`]: crate::result::Result
248+
//! [`.unwrap()`]: crate::result::Result::unwrap
260249
261250
#![stable(feature = "rust1", since = "1.0.0")]
262251

@@ -491,12 +480,10 @@ where
491480
/// }
492481
/// ```
493482
///
494-
/// [`read()`]: trait.Read.html#tymethod.read
495-
/// [`std::io`]: ../../std/io/index.html
496-
/// [`File`]: ../fs/struct.File.html
497-
/// [`BufRead`]: trait.BufRead.html
498-
/// [`BufReader`]: struct.BufReader.html
499-
/// [`&str`]: ../../std/primitive.str.html
483+
/// [`read()`]: Read::read
484+
/// [`&str`]: str
485+
/// [`std::io`]: self
486+
/// [`File`]: crate::fs::File
500487
/// [slice]: ../../std/primitive.slice.html
501488
#[stable(feature = "rust1", since = "1.0.0")]
502489
#[doc(spotlight)]
@@ -535,7 +522,7 @@ pub trait Read {
535522
/// before calling `read`. Calling `read` with an uninitialized `buf` (of the kind one
536523
/// obtains via [`MaybeUninit<T>`]) is not safe, and can lead to undefined behavior.
537524
///
538-
/// [`MaybeUninit<T>`]: ../mem/union.MaybeUninit.html
525+
/// [`MaybeUninit<T>`]: crate::mem::MaybeUninit
539526
///
540527
/// # Errors
541528
///
@@ -550,10 +537,8 @@ pub trait Read {
550537
///
551538
/// [`File`]s implement `Read`:
552539
///
553-
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
554-
/// [`Ok(n)`]: ../../std/result/enum.Result.html#variant.Ok
555-
/// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
556-
/// [`File`]: ../fs/struct.File.html
540+
/// [`Ok(n)`]: Ok
541+
/// [`File`]: crate::fs::File
557542
///
558543
/// ```no_run
559544
/// use std::io;
@@ -620,9 +605,6 @@ pub trait Read {
620605
/// This method is unsafe because a `Read`er could otherwise return a
621606
/// non-zeroing `Initializer` from another `Read` type without an `unsafe`
622607
/// block.
623-
///
624-
/// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop
625-
/// [`Initializer`]: ../../std/io/struct.Initializer.html
626608
#[unstable(feature = "read_initializer", issue = "42788")]
627609
#[inline]
628610
unsafe fn initializer(&self) -> Initializer {
@@ -652,10 +634,9 @@ pub trait Read {
652634
///
653635
/// [`File`]s implement `Read`:
654636
///
655-
/// [`read()`]: trait.Read.html#tymethod.read
656-
/// [`Ok(0)`]: ../../std/result/enum.Result.html#variant.Ok
657-
/// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
658-
/// [`File`]: ../fs/struct.File.html
637+
/// [`read()`]: Read::read
638+
/// [`Ok(0)`]: Ok
639+
/// [`File`]: crate::fs::File
659640
///
660641
/// ```no_run
661642
/// use std::io;
@@ -675,7 +656,7 @@ pub trait Read {
675656
/// (See also the [`std::fs::read`] convenience function for reading from a
676657
/// file.)
677658
///
678-
/// [`std::fs::read`]: ../fs/fn.read.html
659+
/// [`std::fs::read`]: crate::fs::read
679660
#[stable(feature = "rust1", since = "1.0.0")]
680661
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
681662
read_to_end(self, buf)
@@ -693,13 +674,13 @@ pub trait Read {
693674
///
694675
/// See [`read_to_end`][readtoend] for other error semantics.
695676
///
696-
/// [readtoend]: #method.read_to_end
677+
/// [readtoend]: Self::read_to_end
697678
///
698679
/// # Examples
699680
///
700681
/// [`File`][file]s implement `Read`:
701682
///
702-
/// [file]: ../fs/struct.File.html
683+
/// [file]: crate::fs::File
703684
///
704685
/// ```no_run
705686
/// use std::io;
@@ -718,7 +699,7 @@ pub trait Read {
718699
/// (See also the [`std::fs::read_to_string`] convenience function for
719700
/// reading from a file.)
720701
///
721-
/// [`std::fs::read_to_string`]: ../fs/fn.read_to_string.html
702+
/// [`std::fs::read_to_string`]: crate::fs::read_to_string
722703
#[stable(feature = "rust1", since = "1.0.0")]
723704
fn read_to_string(&mut self, buf: &mut String) -> Result<usize> {
724705
// Note that we do *not* call `.read_to_end()` here. We are passing
@@ -764,9 +745,7 @@ pub trait Read {
764745
///
765746
/// [`File`]s implement `Read`:
766747
///
767-
/// [`File`]: ../fs/struct.File.html
768-
/// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
769-
/// [`ErrorKind::UnexpectedEof`]: ../../std/io/enum.ErrorKind.html#variant.UnexpectedEof
748+
/// [`File`]: crate::fs::File
770749
///
771750
/// ```no_run
772751
/// use std::io;
@@ -811,7 +790,7 @@ pub trait Read {
811790
///
812791
/// [`File`][file]s implement `Read`:
813792
///
814-
/// [file]: ../fs/struct.File.html
793+
/// [file]: crate::fs::File
815794
///
816795
/// ```no_run
817796
/// use std::io;
@@ -855,14 +834,10 @@ pub trait Read {
855834
///
856835
/// [`File`][file]s implement `Read`:
857836
///
858-
/// [file]: ../fs/struct.File.html
859-
/// [`Iterator`]: ../../std/iter/trait.Iterator.html
860-
/// [`Result`]: ../../std/result/enum.Result.html
861-
/// [`io::Error`]: ../../std/io/struct.Error.html
862-
/// [`u8`]: ../../std/primitive.u8.html
863-
/// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
864-
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
865-
/// [`None`]: ../../std/option/enum.Option.html#variant.None
837+
/// [file]: crate::fs::File
838+
/// [`Iterator`]: crate::iter::Iterator
839+
/// [`Result`]: crate::result::Result
840+
/// [`io::Error`]: self::Error
866841
///
867842
/// ```no_run
868843
/// use std::io;
@@ -896,7 +871,7 @@ pub trait Read {
896871
///
897872
/// [`File`][file]s implement `Read`:
898873
///
899-
/// [file]: ../fs/struct.File.html
874+
/// [file]: crate::fs::File
900875
///
901876
/// ```no_run
902877
/// use std::io;
@@ -935,9 +910,9 @@ pub trait Read {
935910
///
936911
/// [`File`]s implement `Read`:
937912
///
938-
/// [`File`]: ../fs/struct.File.html
939-
/// [`Ok(0)`]: ../../std/result/enum.Result.html#variant.Ok
940-
/// [`read()`]: trait.Read.html#tymethod.read
913+
/// [`File`]: crate::fs::File
914+
/// [`Ok(0)`]: Ok
915+
/// [`read()`]: Read::read
941916
///
942917
/// ```no_run
943918
/// use std::io;
@@ -1233,8 +1208,8 @@ impl Initializer {
12331208
/// throughout [`std::io`] take and provide types which implement the `Write`
12341209
/// trait.
12351210
///
1236-
/// [`write`]: #tymethod.write
1237-
/// [`flush`]: #tymethod.flush
1211+
/// [`write`]: Self::write
1212+
/// [`flush`]: Self::flush
12381213
/// [`std::io`]: index.html
12391214
///
12401215
/// # Examples
@@ -1260,7 +1235,7 @@ impl Initializer {
12601235
/// The trait also provides convenience methods like [`write_all`], which calls
12611236
/// `write` in a loop until its entire input has been written.
12621237
///
1263-
/// [`write_all`]: #method.write_all
1238+
/// [`write_all`]: Self::write_all
12641239
#[stable(feature = "rust1", since = "1.0.0")]
12651240
#[doc(spotlight)]
12661241
pub trait Write {
@@ -1292,10 +1267,6 @@ pub trait Write {
12921267
/// An error of the [`ErrorKind::Interrupted`] kind is non-fatal and the
12931268
/// write operation should be retried if there is nothing else to do.
12941269
///
1295-
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
1296-
/// [`Ok(n)`]: ../../std/result/enum.Result.html#variant.Ok
1297-
/// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
1298-
///
12991270
/// # Examples
13001271
///
13011272
/// ```no_run
@@ -1381,8 +1352,7 @@ pub trait Write {
13811352
/// This function will return the first error of
13821353
/// non-[`ErrorKind::Interrupted`] kind that [`write`] returns.
13831354
///
1384-
/// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
1385-
/// [`write`]: #tymethod.write
1355+
/// [`write`]: Self::write
13861356
///
13871357
/// # Examples
13881358
///
@@ -1423,8 +1393,7 @@ pub trait Write {
14231393
///
14241394
/// If the buffer contains no data, this will never call [`write_vectored`].
14251395
///
1426-
/// [`write_vectored`]: #method.write_vectored
1427-
/// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
1396+
/// [`write_vectored`]: Self::write_vectored
14281397
///
14291398
/// # Notes
14301399
///
@@ -1480,19 +1449,16 @@ pub trait Write {
14801449
/// encountered.
14811450
///
14821451
/// This method is primarily used to interface with the
1483-
/// [`format_args!`][formatargs] macro, but it is rare that this should
1484-
/// explicitly be called. The [`write!`][write] macro should be favored to
1452+
/// [`format_args!()`] macro, but it is rare that this should
1453+
/// explicitly be called. The [`write!()`][write] macro should be favored to
14851454
/// invoke this method instead.
14861455
///
1487-
/// [formatargs]: ../macro.format_args.html
1488-
/// [write]: ../macro.write.html
1489-
///
14901456
/// This function internally uses the [`write_all`][writeall] method on
14911457
/// this trait and hence will continuously write data so long as no errors
14921458
/// are received. This also means that partial writes are not indicated in
14931459
/// this signature.
14941460
///
1495-
/// [writeall]: #method.write_all
1461+
/// [writeall]: Self::write_all
14961462
///
14971463
/// # Errors
14981464
///
@@ -1589,7 +1555,7 @@ pub trait Write {
15891555
///
15901556
/// [`File`][file]s implement `Seek`:
15911557
///
1592-
/// [file]: ../fs/struct.File.html
1558+
/// [file]: crate::fs::File
15931559
///
15941560
/// ```no_run
15951561
/// use std::io;
@@ -1789,9 +1755,9 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>) -> R
17891755
/// [`BufReader`] to the rescue!
17901756
///
17911757
/// [`BufReader`]: struct.BufReader.html
1792-
/// [`File`]: ../fs/struct.File.html
1793-
/// [`read_line`]: #method.read_line
1794-
/// [`lines`]: #method.lines
1758+
/// [`File`]: crate::fs::File
1759+
/// [`read_line`]: Self::read_line
1760+
/// [`lines`]: Self::lines
17951761
/// [`Read`]: trait.Read.html
17961762
///
17971763
/// ```no_run
@@ -1823,7 +1789,7 @@ pub trait BufRead: Read {
18231789
/// be called with the number of bytes that are consumed from this buffer to
18241790
/// ensure that the bytes are never returned twice.
18251791
///
1826-
/// [`consume`]: #tymethod.consume
1792+
/// [`consume`]: Self::consume
18271793
///
18281794
/// An empty buffer returned indicates that the stream has reached EOF.
18291795
///
@@ -1873,7 +1839,7 @@ pub trait BufRead: Read {
18731839
/// Since `consume()` is meant to be used with [`fill_buf`],
18741840
/// that method's example includes an example of `consume()`.
18751841
///
1876-
/// [`fill_buf`]: #tymethod.fill_buf
1842+
/// [`fill_buf`]: Self::fill_buf
18771843
#[stable(feature = "rust1", since = "1.0.0")]
18781844
fn consume(&mut self, amt: usize);
18791845

@@ -1897,7 +1863,7 @@ pub trait BufRead: Read {
18971863
/// If an I/O error is encountered then all bytes read so far will be
18981864
/// present in `buf` and its length will have been adjusted appropriately.
18991865
///
1900-
/// [`fill_buf`]: #tymethod.fill_buf
1866+
/// [`fill_buf`]: Self::fill_buf
19011867
/// [`ErrorKind::Interrupted`]: enum.ErrorKind.html#variant.Interrupted
19021868
///
19031869
/// # Examples
@@ -1962,7 +1928,7 @@ pub trait BufRead: Read {
19621928
/// error is encountered then `buf` may contain some bytes already read in
19631929
/// the event that all data read so far was valid UTF-8.
19641930
///
1965-
/// [`read_until`]: #method.read_until
1931+
/// [`read_until`]: Self::read_until
19661932
///
19671933
/// # Examples
19681934
///
@@ -2015,9 +1981,9 @@ pub trait BufRead: Read {
20151981
/// This function will yield errors whenever [`read_until`] would have
20161982
/// also yielded an error.
20171983
///
2018-
/// [`io::Result`]: type.Result.html
2019-
/// [`Vec<u8>`]: ../vec/struct.Vec.html
2020-
/// [`read_until`]: #method.read_until
1984+
/// [`io::Result`]: self::Result
1985+
/// [`Vec<u8>`]: crate::vec::Vec
1986+
/// [`read_until`]: Self::read_until
20211987
///
20221988
/// # Examples
20231989
///
@@ -2052,17 +2018,14 @@ pub trait BufRead: Read {
20522018
/// [`io::Result`]`<`[`String`]`>`. Each string returned will *not* have a newline
20532019
/// byte (the 0xA byte) or CRLF (0xD, 0xA bytes) at the end.
20542020
///
2055-
/// [`io::Result`]: type.Result.html
2056-
/// [`String`]: ../string/struct.String.html
2021+
/// [`io::Result`]: self::Result
20572022
///
20582023
/// # Examples
20592024
///
20602025
/// [`std::io::Cursor`][`Cursor`] is a type that implements `BufRead`. In
20612026
/// this example, we use [`Cursor`] to iterate over all the lines in a byte
20622027
/// slice.
20632028
///
2064-
/// [`Cursor`]: struct.Cursor.html
2065-
///
20662029
/// ```
20672030
/// use std::io::{self, BufRead};
20682031
///
@@ -2253,8 +2216,6 @@ impl<T> Take<T> {
22532216
/// This instance may reach `EOF` after reading fewer bytes than indicated by
22542217
/// this method if the underlying [`Read`] instance reaches EOF.
22552218
///
2256-
/// [`Read`]: ../../std/io/trait.Read.html
2257-
///
22582219
/// # Examples
22592220
///
22602221
/// ```no_run

0 commit comments

Comments
 (0)