Rollup merge of #43791 - GuillaumeGomez:file-docs, r=QuietMisdreavus
File docs r? @rust-lang/docs
This commit is contained in:
commit
4f5f3faa7d
@ -28,7 +28,7 @@ use time::SystemTime;
|
||||
/// A reference to an open file on the filesystem.
|
||||
///
|
||||
/// An instance of a `File` can be read and/or written depending on what options
|
||||
/// it was opened with. Files also implement `Seek` to alter the logical cursor
|
||||
/// it was opened with. Files also implement [`Seek`] to alter the logical cursor
|
||||
/// that the file contains internally.
|
||||
///
|
||||
/// Files are automatically closed when they go out of scope.
|
||||
@ -48,7 +48,7 @@ use time::SystemTime;
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// Read the contents of a file into a `String`:
|
||||
/// Read the contents of a file into a [`String`]:
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::fs::File;
|
||||
@ -81,6 +81,8 @@ use time::SystemTime;
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// [`Seek`]: ../io/trait.Seek.html
|
||||
/// [`String`]: ../string/struct.String.html
|
||||
/// [`Read`]: ../io/trait.Read.html
|
||||
/// [`BufReader<R>`]: ../io/struct.BufReader.html
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -104,19 +106,19 @@ pub struct Metadata(fs_imp::FileAttr);
|
||||
/// Iterator over the entries in a directory.
|
||||
///
|
||||
/// This iterator is returned from the [`read_dir`] function of this module and
|
||||
/// will yield instances of `io::Result<DirEntry>`. Through a [`DirEntry`]
|
||||
/// will yield instances of [`io::Result`]`<`[`DirEntry`]`>`. Through a [`DirEntry`]
|
||||
/// information like the entry's path and possibly other metadata can be
|
||||
/// learned.
|
||||
///
|
||||
/// [`read_dir`]: fn.read_dir.html
|
||||
/// [`DirEntry`]: struct.DirEntry.html
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// This [`io::Result`] will be an `Err` if there's some sort of intermittent
|
||||
/// This [`io::Result`] will be an [`Err`] if there's some sort of intermittent
|
||||
/// IO error during iteration.
|
||||
///
|
||||
/// [`read_dir`]: fn.read_dir.html
|
||||
/// [`DirEntry`]: struct.DirEntry.html
|
||||
/// [`io::Result`]: ../io/type.Result.html
|
||||
/// [`Err`]: ../result/enum.Result.html#variant.Err
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[derive(Debug)]
|
||||
pub struct ReadDir(fs_imp::ReadDir);
|
||||
|
@ -17,17 +17,21 @@ use convert::From;
|
||||
/// A specialized [`Result`](../result/enum.Result.html) type for I/O
|
||||
/// operations.
|
||||
///
|
||||
/// This type is broadly used across `std::io` for any operation which may
|
||||
/// This type is broadly used across [`std::io`] for any operation which may
|
||||
/// produce an error.
|
||||
///
|
||||
/// This typedef is generally used to avoid writing out `io::Error` directly and
|
||||
/// is otherwise a direct mapping to `Result`.
|
||||
/// This typedef is generally used to avoid writing out [`io::Error`] directly and
|
||||
/// is otherwise a direct mapping to [`Result`].
|
||||
///
|
||||
/// While usual Rust style is to import types directly, aliases of `Result`
|
||||
/// often are not, to make it easier to distinguish between them. `Result` is
|
||||
/// generally assumed to be `std::result::Result`, and so users of this alias
|
||||
/// While usual Rust style is to import types directly, aliases of [`Result`]
|
||||
/// often are not, to make it easier to distinguish between them. [`Result`] is
|
||||
/// generally assumed to be [`std::result::Result`][`Result`], and so users of this alias
|
||||
/// will generally use `io::Result` instead of shadowing the prelude's import
|
||||
/// of `std::result::Result`.
|
||||
/// of [`std::result::Result`][`Result`].
|
||||
///
|
||||
/// [`std::io`]: ../io/index.html
|
||||
/// [`io::Error`]: ../io/struct.Error.html
|
||||
/// [`Result`]: ../result/enum.Result.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -47,13 +51,16 @@ use convert::From;
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
/// The error type for I/O operations of the `Read`, `Write`, `Seek`, and
|
||||
/// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and
|
||||
/// associated traits.
|
||||
///
|
||||
/// Errors mostly originate from the underlying OS, but custom instances of
|
||||
/// `Error` can be created with crafted error messages and a particular value of
|
||||
/// [`ErrorKind`].
|
||||
///
|
||||
/// [`Read`]: ../io/trait.Read.html
|
||||
/// [`Write`]: ../io/trait.Write.html
|
||||
/// [`Seek`]: ../io/trait.Seek.html
|
||||
/// [`ErrorKind`]: enum.ErrorKind.html
|
||||
#[derive(Debug)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -22,7 +22,7 @@
|
||||
//! you'll see a few different types of I/O throughout the documentation in
|
||||
//! this module: [`File`]s, [`TcpStream`]s, and sometimes even [`Vec<T>`]s. For
|
||||
//! example, [`Read`] adds a [`read`][`Read::read`] method, which we can use on
|
||||
//! `File`s:
|
||||
//! [`File`]s:
|
||||
//!
|
||||
//! ```
|
||||
//! use std::io;
|
||||
@ -146,9 +146,9 @@
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
//! Note that you cannot use the `?` operator in functions that do not return
|
||||
//! a `Result<T, E>` (e.g. `main`). Instead, you can call `.unwrap()` or `match`
|
||||
//! on the return value to catch any possible errors:
|
||||
//! Note that you cannot use the [`?` operator] in functions that do not return
|
||||
//! a [`Result<T, E>`][`Result`] (e.g. `main`). Instead, you can call [`.unwrap()`]
|
||||
//! or `match` on the return value to catch any possible errors:
|
||||
//!
|
||||
//! ```
|
||||
//! use std::io;
|
||||
@ -265,6 +265,8 @@
|
||||
//! [`io::Result`]: type.Result.html
|
||||
//! [`?` operator]: ../../book/first-edition/syntax-index.html
|
||||
//! [`Read::read`]: trait.Read.html#tymethod.read
|
||||
//! [`Result`]: ../result/enum.Result.html
|
||||
//! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap
|
||||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user