//! contract. The implementation of many of these functions are subject to change over
//! time and may call fewer or more syscalls/library functions.
//!
- //! [`Read`]: trait.Read.html
- //! [`Write`]: trait.Write.html
- //! [`Seek`]: trait.Seek.html
- //! [`BufRead`]: trait.BufRead.html
- //! [`File`]: ../fs/struct.File.html
- //! [`TcpStream`]: ../net/struct.TcpStream.html
- //! [`Vec<T>`]: ../vec/struct.Vec.html
- //! [`BufReader`]: struct.BufReader.html
- //! [`BufWriter`]: struct.BufWriter.html
- //! [`Write::write`]: trait.Write.html#tymethod.write
- //! [`io::stdout`]: fn.stdout.html
- //! [`println!`]: ../macro.println.html
- //! [`Lines`]: struct.Lines.html
- //! [`io::Result`]: type.Result.html
+ //! [`File`]: crate::fs::File
+ //! [`TcpStream`]: crate::net::TcpStream
+ //! [`Vec<T>`]: crate::vec::Vec
+ //! [`io::stdout`]: stdout
+ //! [`io::Result`]: crate::io::Result
//! [`?` operator]: ../../book/appendix-02-operators.html
- //! [`Read::read`]: trait.Read.html#tymethod.read
- //! [`Result`]: ../result/enum.Result.html
- //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap
- // ignore-tidy-filelength
+ //! [`Result`]: crate::result::Result
+ //! [`.unwrap()`]: crate::result::Result::unwrap
#![stable(feature = "rust1", since = "1.0.0")]
/// }
/// ```
///
- /// [`read()`]: trait.Read.html#tymethod.read
- /// [`std::io`]: ../../std/io/index.html
- /// [`File`]: ../fs/struct.File.html
- /// [`BufRead`]: trait.BufRead.html
- /// [`BufReader`]: struct.BufReader.html
- /// [`&str`]: ../../std/primitive.str.html
+ /// [`read()`]: Read::read
+ /// [`&str`]: str
+ /// [`std::io`]: self
+ /// [`File`]: crate::fs::File
/// [slice]: ../../std/primitive.slice.html
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(spotlight)]
/// before calling `read`. Calling `read` with an uninitialized `buf` (of the kind one
/// obtains via [`MaybeUninit<T>`]) is not safe, and can lead to undefined behavior.
///
- /// [`MaybeUninit<T>`]: ../mem/union.MaybeUninit.html
+ /// [`MaybeUninit<T>`]: crate::mem::MaybeUninit
///
/// # Errors
///
///
/// [`File`]s implement `Read`:
///
- /// [`Err`]: ../../std/result/enum.Result.html#variant.Err
- /// [`Ok(n)`]: ../../std/result/enum.Result.html#variant.Ok
- /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
- /// [`File`]: ../fs/struct.File.html
+ /// [`Ok(n)`]: Ok
+ /// [`File`]: crate::fs::File
///
/// ```no_run
/// use std::io;
/// This method is unsafe because a `Read`er could otherwise return a
/// non-zeroing `Initializer` from another `Read` type without an `unsafe`
/// block.
- ///
- /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop
- /// [`Initializer`]: ../../std/io/struct.Initializer.html
#[unstable(feature = "read_initializer", issue = "42788")]
#[inline]
unsafe fn initializer(&self) -> Initializer {
///
/// [`File`]s implement `Read`:
///
- /// [`read()`]: trait.Read.html#tymethod.read
- /// [`Ok(0)`]: ../../std/result/enum.Result.html#variant.Ok
- /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
- /// [`File`]: ../fs/struct.File.html
+ /// [`read()`]: Read::read
+ /// [`Ok(0)`]: Ok
+ /// [`File`]: crate::fs::File
///
/// ```no_run
/// use std::io;
/// (See also the [`std::fs::read`] convenience function for reading from a
/// file.)
///
- /// [`std::fs::read`]: ../fs/fn.read.html
+ /// [`std::fs::read`]: crate::fs::read
#[stable(feature = "rust1", since = "1.0.0")]
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
read_to_end(self, buf)
///
/// See [`read_to_end`][readtoend] for other error semantics.
///
- /// [readtoend]: #method.read_to_end
+ /// [readtoend]: Self::read_to_end
///
/// # Examples
///
/// [`File`][file]s implement `Read`:
///
- /// [file]: ../fs/struct.File.html
+ /// [file]: crate::fs::File
///
/// ```no_run
/// use std::io;
/// (See also the [`std::fs::read_to_string`] convenience function for
/// reading from a file.)
///
- /// [`std::fs::read_to_string`]: ../fs/fn.read_to_string.html
+ /// [`std::fs::read_to_string`]: crate::fs::read_to_string
#[stable(feature = "rust1", since = "1.0.0")]
fn read_to_string(&mut self, buf: &mut String) -> Result<usize> {
// Note that we do *not* call `.read_to_end()` here. We are passing
/// No guarantees are provided about the contents of `buf` when this
/// function is called, implementations cannot rely on any property of the
/// contents of `buf` being true. It is recommended that implementations
- /// only write data to `buf` instead of reading its contents.
+ /// only write data to `buf` instead of reading its contents. The
+ /// documentation on [`read`] has a more detailed explanation on this
+ /// subject.
///
/// # Errors
///
///
/// [`File`]s implement `Read`:
///
- /// [`File`]: ../fs/struct.File.html
- /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
- /// [`ErrorKind::UnexpectedEof`]: ../../std/io/enum.ErrorKind.html#variant.UnexpectedEof
+ /// [`read`]: Read::read
+ /// [`File`]: crate::fs::File
///
/// ```no_run
/// use std::io;
///
/// [`File`][file]s implement `Read`:
///
- /// [file]: ../fs/struct.File.html
+ /// [file]: crate::fs::File
///
/// ```no_run
/// use std::io;
///
/// [`File`][file]s implement `Read`:
///
- /// [file]: ../fs/struct.File.html
- /// [`Iterator`]: ../../std/iter/trait.Iterator.html
- /// [`Result`]: ../../std/result/enum.Result.html
- /// [`io::Error`]: ../../std/io/struct.Error.html
- /// [`u8`]: ../../std/primitive.u8.html
- /// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
- /// [`Err`]: ../../std/result/enum.Result.html#variant.Err
- /// [`None`]: ../../std/option/enum.Option.html#variant.None
+ /// [file]: crate::fs::File
+ /// [`Iterator`]: crate::iter::Iterator
+ /// [`Result`]: crate::result::Result
+ /// [`io::Error`]: self::Error
///
/// ```no_run
/// use std::io;
///
/// [`File`][file]s implement `Read`:
///
- /// [file]: ../fs/struct.File.html
+ /// [file]: crate::fs::File
///
/// ```no_run
/// use std::io;
///
/// [`File`]s implement `Read`:
///
- /// [`File`]: ../fs/struct.File.html
- /// [`Ok(0)`]: ../../std/result/enum.Result.html#variant.Ok
- /// [`read()`]: trait.Read.html#tymethod.read
+ /// [`File`]: crate::fs::File
+ /// [`Ok(0)`]: Ok
+ /// [`read()`]: Read::read
///
/// ```no_run
/// use std::io;
/// throughout [`std::io`] take and provide types which implement the `Write`
/// trait.
///
- /// [`write`]: #tymethod.write
- /// [`flush`]: #tymethod.flush
+ /// [`write`]: Self::write
+ /// [`flush`]: Self::flush
/// [`std::io`]: index.html
///
/// # Examples
/// The trait also provides convenience methods like [`write_all`], which calls
/// `write` in a loop until its entire input has been written.
///
- /// [`write_all`]: #method.write_all
+ /// [`write_all`]: Self::write_all
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(spotlight)]
pub trait Write {
/// An error of the [`ErrorKind::Interrupted`] kind is non-fatal and the
/// write operation should be retried if there is nothing else to do.
///
- /// [`Err`]: ../../std/result/enum.Result.html#variant.Err
- /// [`Ok(n)`]: ../../std/result/enum.Result.html#variant.Ok
- /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
- ///
/// # Examples
///
/// ```no_run
/// This function will return the first error of
/// non-[`ErrorKind::Interrupted`] kind that [`write`] returns.
///
- /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
- /// [`write`]: #tymethod.write
+ /// [`write`]: Self::write
///
/// # Examples
///
///
/// If the buffer contains no data, this will never call [`write_vectored`].
///
- /// [`write_vectored`]: #method.write_vectored
- /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
+ /// [`write_vectored`]: Self::write_vectored
///
/// # Notes
///
/// encountered.
///
/// This method is primarily used to interface with the
- /// [`format_args!`][formatargs] macro, but it is rare that this should
- /// explicitly be called. The [`write!`][write] macro should be favored to
+ /// [`format_args!()`] macro, but it is rare that this should
+ /// explicitly be called. The [`write!()`] macro should be favored to
/// invoke this method instead.
///
- /// [formatargs]: ../macro.format_args.html
- /// [write]: ../macro.write.html
- ///
/// This function internally uses the [`write_all`][writeall] method on
/// this trait and hence will continuously write data so long as no errors
/// are received. This also means that partial writes are not indicated in
/// this signature.
///
- /// [writeall]: #method.write_all
+ /// [writeall]: Self::write_all
///
/// # Errors
///
///
/// [`File`][file]s implement `Seek`:
///
- /// [file]: ../fs/struct.File.html
+ /// [file]: crate::fs::File
///
/// ```no_run
/// use std::io;
/// [`BufReader`] to the rescue!
///
/// [`BufReader`]: struct.BufReader.html
- /// [`File`]: ../fs/struct.File.html
- /// [`read_line`]: #method.read_line
- /// [`lines`]: #method.lines
+ /// [`File`]: crate::fs::File
+ /// [`read_line`]: Self::read_line
+ /// [`lines`]: Self::lines
/// [`Read`]: trait.Read.html
///
/// ```no_run
/// be called with the number of bytes that are consumed from this buffer to
/// ensure that the bytes are never returned twice.
///
- /// [`consume`]: #tymethod.consume
+ /// [`consume`]: Self::consume
///
/// An empty buffer returned indicates that the stream has reached EOF.
///
/// Since `consume()` is meant to be used with [`fill_buf`],
/// that method's example includes an example of `consume()`.
///
- /// [`fill_buf`]: #tymethod.fill_buf
+ /// [`fill_buf`]: Self::fill_buf
#[stable(feature = "rust1", since = "1.0.0")]
fn consume(&mut self, amt: usize);
/// If an I/O error is encountered then all bytes read so far will be
/// present in `buf` and its length will have been adjusted appropriately.
///
- /// [`fill_buf`]: #tymethod.fill_buf
+ /// [`fill_buf`]: Self::fill_buf
/// [`ErrorKind::Interrupted`]: enum.ErrorKind.html#variant.Interrupted
///
/// # Examples
/// error is encountered then `buf` may contain some bytes already read in
/// the event that all data read so far was valid UTF-8.
///
- /// [`read_until`]: #method.read_until
+ /// [`read_until`]: Self::read_until
///
/// # Examples
///
/// This function will yield errors whenever [`read_until`] would have
/// also yielded an error.
///
- /// [`io::Result`]: type.Result.html
- /// [`Vec<u8>`]: ../vec/struct.Vec.html
- /// [`read_until`]: #method.read_until
+ /// [`io::Result`]: self::Result
+ /// [`Vec<u8>`]: crate::vec::Vec
+ /// [`read_until`]: Self::read_until
///
/// # Examples
///
/// [`io::Result`]`<`[`String`]`>`. Each string returned will *not* have a newline
/// byte (the 0xA byte) or CRLF (0xD, 0xA bytes) at the end.
///
- /// [`io::Result`]: type.Result.html
- /// [`String`]: ../string/struct.String.html
+ /// [`io::Result`]: self::Result
///
/// # Examples
///
/// this example, we use [`Cursor`] to iterate over all the lines in a byte
/// slice.
///
- /// [`Cursor`]: struct.Cursor.html
- ///
/// ```
/// use std::io::{self, BufRead};
///
/// This instance may reach `EOF` after reading fewer bytes than indicated by
/// this method if the underlying [`Read`] instance reaches EOF.
///
- /// [`Read`]: ../../std/io/trait.Read.html
- ///
/// # Examples
///
/// ```no_run