Skip to content

Commit f4fe270

Browse files
authored
Rollup merge of rust-lang#43791 - GuillaumeGomez:file-docs, r=QuietMisdreavus
File docs r? @rust-lang/docs
2 parents 0814eb9 + 972d67c commit f4fe270

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

src/libstd/fs.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use time::SystemTime;
2828
/// A reference to an open file on the filesystem.
2929
///
3030
/// An instance of a `File` can be read and/or written depending on what options
31-
/// it was opened with. Files also implement `Seek` to alter the logical cursor
31+
/// it was opened with. Files also implement [`Seek`] to alter the logical cursor
3232
/// that the file contains internally.
3333
///
3434
/// Files are automatically closed when they go out of scope.
@@ -48,7 +48,7 @@ use time::SystemTime;
4848
/// # }
4949
/// ```
5050
///
51-
/// Read the contents of a file into a `String`:
51+
/// Read the contents of a file into a [`String`]:
5252
///
5353
/// ```no_run
5454
/// use std::fs::File;
@@ -81,6 +81,8 @@ use time::SystemTime;
8181
/// # }
8282
/// ```
8383
///
84+
/// [`Seek`]: ../io/trait.Seek.html
85+
/// [`String`]: ../string/struct.String.html
8486
/// [`Read`]: ../io/trait.Read.html
8587
/// [`BufReader<R>`]: ../io/struct.BufReader.html
8688
#[stable(feature = "rust1", since = "1.0.0")]
@@ -104,19 +106,19 @@ pub struct Metadata(fs_imp::FileAttr);
104106
/// Iterator over the entries in a directory.
105107
///
106108
/// This iterator is returned from the [`read_dir`] function of this module and
107-
/// will yield instances of `io::Result<DirEntry>`. Through a [`DirEntry`]
109+
/// will yield instances of [`io::Result`]`<`[`DirEntry`]`>`. Through a [`DirEntry`]
108110
/// information like the entry's path and possibly other metadata can be
109111
/// learned.
110112
///
111-
/// [`read_dir`]: fn.read_dir.html
112-
/// [`DirEntry`]: struct.DirEntry.html
113-
///
114113
/// # Errors
115114
///
116-
/// This [`io::Result`] will be an `Err` if there's some sort of intermittent
115+
/// This [`io::Result`] will be an [`Err`] if there's some sort of intermittent
117116
/// IO error during iteration.
118117
///
118+
/// [`read_dir`]: fn.read_dir.html
119+
/// [`DirEntry`]: struct.DirEntry.html
119120
/// [`io::Result`]: ../io/type.Result.html
121+
/// [`Err`]: ../result/enum.Result.html#variant.Err
120122
#[stable(feature = "rust1", since = "1.0.0")]
121123
#[derive(Debug)]
122124
pub struct ReadDir(fs_imp::ReadDir);

src/libstd/io/error.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,21 @@ use convert::From;
1717
/// A specialized [`Result`](../result/enum.Result.html) type for I/O
1818
/// operations.
1919
///
20-
/// This type is broadly used across `std::io` for any operation which may
20+
/// This type is broadly used across [`std::io`] for any operation which may
2121
/// produce an error.
2222
///
23-
/// This typedef is generally used to avoid writing out `io::Error` directly and
24-
/// is otherwise a direct mapping to `Result`.
23+
/// This typedef is generally used to avoid writing out [`io::Error`] directly and
24+
/// is otherwise a direct mapping to [`Result`].
2525
///
26-
/// While usual Rust style is to import types directly, aliases of `Result`
27-
/// often are not, to make it easier to distinguish between them. `Result` is
28-
/// generally assumed to be `std::result::Result`, and so users of this alias
26+
/// While usual Rust style is to import types directly, aliases of [`Result`]
27+
/// often are not, to make it easier to distinguish between them. [`Result`] is
28+
/// generally assumed to be [`std::result::Result`][`Result`], and so users of this alias
2929
/// will generally use `io::Result` instead of shadowing the prelude's import
30-
/// of `std::result::Result`.
30+
/// of [`std::result::Result`][`Result`].
31+
///
32+
/// [`std::io`]: ../io/index.html
33+
/// [`io::Error`]: ../io/struct.Error.html
34+
/// [`Result`]: ../result/enum.Result.html
3135
///
3236
/// # Examples
3337
///
@@ -47,13 +51,16 @@ use convert::From;
4751
#[stable(feature = "rust1", since = "1.0.0")]
4852
pub type Result<T> = result::Result<T, Error>;
4953

50-
/// The error type for I/O operations of the `Read`, `Write`, `Seek`, and
54+
/// The error type for I/O operations of the [`Read`], [`Write`], [`Seek`], and
5155
/// associated traits.
5256
///
5357
/// Errors mostly originate from the underlying OS, but custom instances of
5458
/// `Error` can be created with crafted error messages and a particular value of
5559
/// [`ErrorKind`].
5660
///
61+
/// [`Read`]: ../io/trait.Read.html
62+
/// [`Write`]: ../io/trait.Write.html
63+
/// [`Seek`]: ../io/trait.Seek.html
5764
/// [`ErrorKind`]: enum.ErrorKind.html
5865
#[derive(Debug)]
5966
#[stable(feature = "rust1", since = "1.0.0")]

src/libstd/io/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
//! you'll see a few different types of I/O throughout the documentation in
2323
//! this module: [`File`]s, [`TcpStream`]s, and sometimes even [`Vec<T>`]s. For
2424
//! example, [`Read`] adds a [`read`][`Read::read`] method, which we can use on
25-
//! `File`s:
25+
//! [`File`]s:
2626
//!
2727
//! ```
2828
//! use std::io;
@@ -146,9 +146,9 @@
146146
//! # }
147147
//! ```
148148
//!
149-
//! Note that you cannot use the `?` operator in functions that do not return
150-
//! a `Result<T, E>` (e.g. `main`). Instead, you can call `.unwrap()` or `match`
151-
//! on the return value to catch any possible errors:
149+
//! Note that you cannot use the [`?` operator] in functions that do not return
150+
//! a [`Result<T, E>`][`Result`] (e.g. `main`). Instead, you can call [`.unwrap()`]
151+
//! or `match` on the return value to catch any possible errors:
152152
//!
153153
//! ```
154154
//! use std::io;
@@ -265,6 +265,8 @@
265265
//! [`io::Result`]: type.Result.html
266266
//! [`?` operator]: ../../book/first-edition/syntax-index.html
267267
//! [`Read::read`]: trait.Read.html#tymethod.read
268+
//! [`Result`]: ../result/enum.Result.html
269+
//! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap
268270
269271
#![stable(feature = "rust1", since = "1.0.0")]
270272

0 commit comments

Comments
 (0)