about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-05-19 02:31:44 +0200
committerGitHub <noreply@github.com>2019-05-19 02:31:44 +0200
commitf9d58c71883b54082971449643e8a194ee2622de (patch)
tree259bfd14f365fc7fd569f9fad5ead6620a3afd11 /src/libstd
parent94da30728f605e3c68bbf5226d12a1dbd4234365 (diff)
parent01cf36ebde50521993a61013487059be5f568c19 (diff)
downloadrust-f9d58c71883b54082971449643e8a194ee2622de.tar.gz
rust-f9d58c71883b54082971449643e8a194ee2622de.zip
Rollup merge of #60945 - blkerby:fill_buf_nll_doc_example, r=shepmaster
Simplify BufRead::fill_buf doc example using NLL

With non-lexical lifetimes, in this example it is no longer necessary to use a block to end the borrow early.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/mod.rs13
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")]