Skip to content

Commit d3ae7a4

Browse files
author
kiseitai3
committed
docs: cleaning up my new section per Trevor's suggestions.
1 parent bfe5a96 commit d3ae7a4

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

library/std/src/io/mod.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -922,12 +922,14 @@ pub trait Read {
922922
/// `read_to_end` attempts to read a source until EOF, but many sources are continuous streams
923923
/// that do not send EOF. In these cases, `read_to_end` will block indefinitely. Standard input
924924
/// is one such stream which may be finite if piped, but is typically continuous. For example,
925-
/// `cat <file> | <my_rust_program>` will correctly terminate with an `EOF` upon closure of cat.
925+
/// `cat file | my-rust-program` will correctly terminate with an `EOF` upon closure of cat.
926926
/// Reading user input or running programs that remain open indefinitely will never terminate
927-
/// the stream with `EOF` (e.g. `yes "Data" | pv | <my_rust_program`).
927+
/// the stream with `EOF` (e.g. `yes | my-rust-program`).
928928
///
929929
/// Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution
930930
///
931+
///[`read`]: Read::read
932+
///
931933
/// [`Vec::try_reserve`]: crate::vec::Vec::try_reserve
932934
#[stable(feature = "rust1", since = "1.0.0")]
933935
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
@@ -975,13 +977,15 @@ pub trait Read {
975977
///
976978
/// `read_to_string` attempts to read a source until EOF, but many sources are continuous streams
977979
/// that do not send EOF. In these cases, `read_to_string` will block indefinitely. Standard input
978-
/// is one such stream which may be finite if piped, but is typically continuous. FFor example,
979-
/// `cat <file> | <my_rust_program>` will correctly terminate with an `EOF` upon closure of cat.
980+
/// is one such stream which may be finite if piped, but is typically continuous. For example,
981+
/// `cat file | my-rust-program` will correctly terminate with an `EOF` upon closure of cat.
980982
/// Reading user input or running programs that remain open indefinitely will never terminate
981-
/// the stream with `EOF` (e.g. `yes "Data" | pv | <my_rust_program`).
983+
/// the stream with `EOF` (e.g. `yes | my-rust-program`).
982984
///
983985
/// Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution
984986
///
987+
///[`read`]: Read::read
988+
///
985989
/// [`std::fs::read_to_string`]: crate::fs::read_to_string
986990
#[stable(feature = "rust1", since = "1.0.0")]
987991
fn read_to_string(&mut self, buf: &mut String) -> Result<usize> {
@@ -1290,11 +1294,14 @@ pub trait Read {
12901294
/// `read_to_string` attempts to read a source until EOF, but many sources are continuous streams
12911295
/// that do not send EOF. In these cases, `read_to_string` will block indefinitely. Standard input
12921296
/// is one such stream which may be finite if piped, but is typically continuous. For example,
1293-
/// `cat <file> | <my_rust_program>` will correctly terminate with an `EOF` upon closure of cat.
1297+
/// `cat file | my-rust-program` will correctly terminate with an `EOF` upon closure of cat.
12941298
/// Reading user input or running programs that remain open indefinitely will never terminate
1295-
/// the stream with `EOF` (e.g. `yes "Data" | pv | <my_rust_program`).
1299+
/// the stream with `EOF` (e.g. `yes | my-rust-program`).
12961300
///
12971301
/// Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution
1302+
///
1303+
///[`read`]: Read::read
1304+
///
12981305
#[stable(feature = "io_read_to_string", since = "1.65.0")]
12991306
pub fn read_to_string<R: Read>(mut reader: R) -> Result<String> {
13001307
let mut buf = String::new();

0 commit comments

Comments
 (0)