Skip to content

Commit 588786a

Browse files
committed
Add error docs
1 parent 4ee6d1b commit 588786a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

library/std/src/io/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,14 @@ pub trait Read {
951951
/// function avoids having to create a variable first and provides more type
952952
/// safety since you can only get the buffer out if there were no errors. (If you
953953
/// use [`Read::read_to_string`] you have to remember to check whether the read
954-
/// succeeded because otherwise your buffer will be empty.)
954+
/// succeeded because otherwise your buffer will be empty or only partially full.)
955+
///
956+
/// # Errors
957+
///
958+
/// This function forces you to handle errors because the output (the `String`)
959+
/// is wrapped in a [`Result`]. See [`Read::read_to_string`] for the errors
960+
/// that can occur. If any error occurs, you will get an [`Err`], so you
961+
/// don't have to worry about your buffer being empty or partially full.
955962
///
956963
/// # Examples
957964
///

0 commit comments

Comments
 (0)