diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-01-15 11:28:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-15 11:28:24 +0100 |
| commit | d878ad0559ed1be0d0a0e3cdc2a62a9480e42cb8 (patch) | |
| tree | 708afb72e4210b26c05b2807662b03c2ced948f6 | |
| parent | 1b241bb70365b06ccb6e0bc98fceb5cf76761d7b (diff) | |
| parent | aa0ce4a20ee54eba911f2225644db768f6cad7ec (diff) | |
| download | rust-d878ad0559ed1be0d0a0e3cdc2a62a9480e42cb8.tar.gz rust-d878ad0559ed1be0d0a0e3cdc2a62a9480e42cb8.zip | |
Rollup merge of #92863 - camelid:read_to_string-rm-mut, r=m-ou-se
Remove `&mut` from `io::read_to_string` signature ``@m-ou-se`` [realized][1] that because `Read` is implemented for `&mut impl Read`, there's no need to take `&mut` in `io::read_to_string`. Removing the `&mut` from the signature allows users to remove the `&mut` from their calls (and thus pass an owned reader) if they don't use the reader later. r? `@m-ou-se` [1]: https://github.com/rust-lang/rust/issues/80218#issuecomment-874322129
| -rw-r--r-- | library/std/src/io/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 358ef22e708..824938ce38e 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -1031,14 +1031,14 @@ pub trait Read { /// /// # use std::io; /// fn main() -> io::Result<()> { -/// let stdin = io::read_to_string(&mut io::stdin())?; +/// let stdin = io::read_to_string(io::stdin())?; /// println!("Stdin was:"); /// println!("{}", stdin); /// Ok(()) /// } /// ``` #[unstable(feature = "io_read_to_string", issue = "80218")] -pub fn read_to_string<R: Read>(reader: &mut R) -> Result<String> { +pub fn read_to_string<R: Read>(mut reader: R) -> Result<String> { let mut buf = String::new(); reader.read_to_string(&mut buf)?; Ok(buf) |
