mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-23 12:23:22 +00:00
Rollup merge of #100337 - camelid:stabilize-io_read_to_string, r=JohnTitor
Stabilize `std::io::read_to_string` Closes #80218. 🎉 This PR stabilizes the `std::io::read_to_string` function, with the following public API: ```rust pub fn read_to_string<R: Read>(reader: R) -> Result<String>; ``` It's analogous to `std::fs::read_to_string` for files, but it works on anything that implements `io::Read`, including `io::stdin()`. See the tracking issue (#80218) or documentation for details.
This commit is contained in:
commit
9f7e20ba35
@ -1037,8 +1037,6 @@ pub trait Read {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
/// #![feature(io_read_to_string)]
|
||||
///
|
||||
/// # use std::io;
|
||||
/// fn main() -> io::Result<()> {
|
||||
/// let stdin = io::read_to_string(io::stdin())?;
|
||||
@ -1047,7 +1045,7 @@ pub trait Read {
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// ```
|
||||
#[unstable(feature = "io_read_to_string", issue = "80218")]
|
||||
#[stable(feature = "io_read_to_string", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub fn read_to_string<R: Read>(mut reader: R) -> Result<String> {
|
||||
let mut buf = String::new();
|
||||
reader.read_to_string(&mut buf)?;
|
||||
|
Loading…
Reference in New Issue
Block a user