1
Fork 0

Move to intra doc links for std::io

This commit is contained in:
Alexis Bourget 2020-08-18 19:36:52 +02:00
parent 2c3dc04ea4
commit 5d49c0e55a
6 changed files with 126 additions and 146 deletions

View file

@ -240,9 +240,9 @@
//!
//! [`File`]: crate::fs::File
//! [`TcpStream`]: crate::net::TcpStream
//! [`Vec<T>`]: crate::vec::Vec
//! [`Vec<T>`]: Vec
//! [`io::stdout`]: stdout
//! [`io::Result`]: crate::io::Result
//! [`io::Result`]: self::Result
//! [`?` operator]: ../../book/appendix-02-operators.html
//! [`Result`]: crate::result::Result
//! [`.unwrap()`]: crate::result::Result::unwrap
@ -479,11 +479,11 @@ where
/// }
/// ```
///
/// [`read()`]: Read::read
/// [`read()`]: Self::read
/// [`&str`]: str
/// [`std::io`]: self
/// [`File`]: crate::fs::File
/// [slice]: ../../std/primitive.slice.html
/// [slice]: crate::slice
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(spotlight)]
pub trait Read {
@ -633,7 +633,7 @@ pub trait Read {
///
/// [`File`]s implement `Read`:
///
/// [`read()`]: Read::read
/// [`read()`]: Self::read
/// [`Ok(0)`]: Ok
/// [`File`]: crate::fs::File
///
@ -671,15 +671,15 @@ pub trait Read {
/// If the data in this stream is *not* valid UTF-8 then an error is
/// returned and `buf` is unchanged.
///
/// See [`read_to_end`][readtoend] for other error semantics.
/// See [`read_to_end`] for other error semantics.
///
/// [readtoend]: Self::read_to_end
/// [`read_to_end`]: Self::read_to_end
///
/// # Examples
///
/// [`File`][file]s implement `Read`:
/// [`File`]s implement `Read`:
///
/// [file]: crate::fs::File
/// [`File`]: crate::fs::File
///
/// ```no_run
/// use std::io;
@ -746,7 +746,7 @@ pub trait Read {
///
/// [`File`]s implement `Read`:
///
/// [`read`]: Read::read
/// [`read`]: Self::read
/// [`File`]: crate::fs::File
///
/// ```no_run
@ -790,9 +790,9 @@ pub trait Read {
///
/// # Examples
///
/// [`File`][file]s implement `Read`:
/// [`File`]s implement `Read`:
///
/// [file]: crate::fs::File
/// [`File`]: crate::fs::File
///
/// ```no_run
/// use std::io;
@ -834,10 +834,9 @@ pub trait Read {
///
/// # Examples
///
/// [`File`][file]s implement `Read`:
/// [`File`]s implement `Read`:
///
/// [file]: crate::fs::File
/// [`Iterator`]: crate::iter::Iterator
/// [`File`]: crate::fs::File
/// [`Result`]: crate::result::Result
/// [`io::Error`]: self::Error
///
@ -871,9 +870,9 @@ pub trait Read {
///
/// # Examples
///
/// [`File`][file]s implement `Read`:
/// [`File`]s implement `Read`:
///
/// [file]: crate::fs::File
/// [`File`]: crate::fs::File
///
/// ```no_run
/// use std::io;
@ -1283,30 +1282,36 @@ pub trait Write {
/// Ok(())
/// }
/// ```
///
/// [`Ok(n)`]: Ok
#[stable(feature = "rust1", since = "1.0.0")]
fn write(&mut self, buf: &[u8]) -> Result<usize>;
/// Like `write`, except that it writes from a slice of buffers.
/// Like [`write`], except that it writes from a slice of buffers.
///
/// Data is copied from each buffer in order, with the final buffer
/// read from possibly being only partially consumed. This method must
/// behave as a call to `write` with the buffers concatenated would.
/// behave as a call to [`write`] with the buffers concatenated would.
///
/// The default implementation calls `write` with either the first nonempty
/// The default implementation calls [`write`] with either the first nonempty
/// buffer provided, or an empty one if none exists.
///
/// [`write`]: Self::write
#[stable(feature = "iovec", since = "1.36.0")]
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize> {
default_write_vectored(|b| self.write(b), bufs)
}
/// Determines if this `Write`er has an efficient `write_vectored`
/// Determines if this `Write`er has an efficient [`write_vectored`]
/// implementation.
///
/// If a `Write`er does not override the default `write_vectored`
/// If a `Write`er does not override the default [`write_vectored`]
/// implementation, code using it may want to avoid the method all together
/// and coalesce writes into a single buffer for higher performance.
///
/// The default implementation returns `false`.
///
/// [`write_vectored`]: Self::write_vectored
#[unstable(feature = "can_vector", issue = "69941")]
fn is_write_vectored(&self) -> bool {
false
@ -1399,16 +1404,15 @@ pub trait Write {
///
/// # Notes
///
///
/// Unlike `io::Write::write_vectored`, this takes a *mutable* reference to
/// a slice of `IoSlice`s, not an immutable one. That's because we need to
/// Unlike [`write_vectored`], this takes a *mutable* reference to
/// a slice of [`IoSlice`]s, not an immutable one. That's because we need to
/// modify the slice to keep track of the bytes already written.
///
/// Once this function returns, the contents of `bufs` are unspecified, as
/// this depends on how many calls to `write_vectored` were necessary. It is
/// this depends on how many calls to [`write_vectored`] were necessary. It is
/// best to understand this function as taking ownership of `bufs` and to
/// not use `bufs` afterwards. The underlying buffers, to which the
/// `IoSlice`s point (but not the `IoSlice`s themselves), are unchanged and
/// [`IoSlice`]s point (but not the [`IoSlice`]s themselves), are unchanged and
/// can be reused.
///
/// # Examples
@ -1458,12 +1462,12 @@ pub trait Write {
/// explicitly be called. The [`write!()`] macro should be favored to
/// invoke this method instead.
///
/// This function internally uses the [`write_all`][writeall] method on
/// This function internally uses the [`write_all`] 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]: Self::write_all
/// [`write_all`]: Self::write_all
///
/// # Errors
///
@ -1558,9 +1562,9 @@ pub trait Write {
///
/// # Examples
///
/// [`File`][file]s implement `Seek`:
/// [`File`]s implement `Seek`:
///
/// [file]: crate::fs::File
/// [`File`]: crate::fs::File
///
/// ```no_run
/// use std::io;
@ -1610,7 +1614,6 @@ pub trait Seek {
/// data is appended to a file). So calling this method multiple times does
/// not necessarily return the same length each time.
///
///
/// # Example
///
/// ```no_run
@ -1646,7 +1649,6 @@ pub trait Seek {
///
/// This is equivalent to `self.seek(SeekFrom::Current(0))`.
///
///
/// # Example
///
/// ```no_run
@ -1775,7 +1777,6 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>) -> R
/// Ok(())
/// }
/// ```
///
#[stable(feature = "rust1", since = "1.0.0")]
pub trait BufRead: Read {
/// Returns the contents of the internal buffer, filling it with more data
@ -1901,22 +1902,24 @@ pub trait BufRead: Read {
read_until(self, byte, buf)
}
/// Read all bytes until a newline (the 0xA byte) is reached, and append
/// Read all bytes until a newline (the `0xA` byte) is reached, and append
/// them to the provided buffer.
///
/// This function will read bytes from the underlying stream until the
/// newline delimiter (the 0xA byte) or EOF is found. Once found, all bytes
/// newline delimiter (the `0xA` byte) or EOF is found. Once found, all bytes
/// up to, and including, the delimiter (if found) will be appended to
/// `buf`.
///
/// If successful, this function will return the total number of bytes read.
///
/// If this function returns `Ok(0)`, the stream has reached EOF.
/// If this function returns [`Ok(0)`], the stream has reached EOF.
///
/// This function is blocking and should be used carefully: it is possible for
/// an attacker to continuously send bytes without ever sending a newline
/// or EOF.
///
/// [`Ok(0)`]: Ok
///
/// # Errors
///
/// This function has the same error semantics as [`read_until`] and will
@ -1976,7 +1979,7 @@ pub trait BufRead: Read {
/// also yielded an error.
///
/// [`io::Result`]: self::Result
/// [`Vec<u8>`]: crate::vec::Vec
/// [`Vec<u8>`]: Vec
/// [`read_until`]: Self::read_until
///
/// # Examples
@ -2008,7 +2011,7 @@ pub trait BufRead: Read {
///
/// The iterator returned from this function will yield instances of
/// [`io::Result`]`<`[`String`]`>`. Each string returned will *not* have a newline
/// byte (the 0xA byte) or CRLF (0xD, 0xA bytes) at the end.
/// byte (the `0xA` byte) or CRLF (0xD, 0xA bytes) at the end.
///
/// [`io::Result`]: self::Result
///