diff options
| author | Brent Kerby <blkerby@gmail.com> | 2019-05-18 12:38:06 -0600 |
|---|---|---|
| committer | Brent Kerby <blkerby@gmail.com> | 2019-05-18 13:30:44 -0600 |
| commit | 01cf36ebde50521993a61013487059be5f568c19 (patch) | |
| tree | 94d55c487b2302dd93bb33d0c49d4d5bd8b2af8f /src/libstd | |
| parent | 9a9df55f074806890e4f6388ab79a71ad10e0c1d (diff) | |
| download | rust-01cf36ebde50521993a61013487059be5f568c19.tar.gz rust-01cf36ebde50521993a61013487059be5f568c19.zip | |
Simplify BufRead doc example using NLL
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/mod.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 8fea6251e65..917199f8ea8 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1579,18 +1579,13 @@ pub trait BufRead: Read { /// let stdin = io::stdin(); /// let mut stdin = stdin.lock(); /// - /// // we can't have two `&mut` references to `stdin`, so use a block - /// // to end the borrow early. - /// let length = { - /// let buffer = stdin.fill_buf().unwrap(); + /// let buffer = stdin.fill_buf().unwrap(); /// - /// // work with buffer - /// println!("{:?}", buffer); - /// - /// buffer.len() - /// }; + /// // work with buffer + /// println!("{:?}", buffer); /// /// // ensure the bytes we worked with aren't returned again later + /// let length = buffer.len(); /// stdin.consume(length); /// ``` #[stable(feature = "rust1", since = "1.0.0")] |
