Skip to content

Commit f9d58c7

Browse files
authored
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.
2 parents 94da307 + 01cf36e commit f9d58c7

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/libstd/io/mod.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -1579,18 +1579,13 @@ pub trait BufRead: Read {
15791579
/// let stdin = io::stdin();
15801580
/// let mut stdin = stdin.lock();
15811581
///
1582-
/// // we can't have two `&mut` references to `stdin`, so use a block
1583-
/// // to end the borrow early.
1584-
/// let length = {
1585-
/// let buffer = stdin.fill_buf().unwrap();
1582+
/// let buffer = stdin.fill_buf().unwrap();
15861583
///
1587-
/// // work with buffer
1588-
/// println!("{:?}", buffer);
1589-
///
1590-
/// buffer.len()
1591-
/// };
1584+
/// // work with buffer
1585+
/// println!("{:?}", buffer);
15921586
///
15931587
/// // ensure the bytes we worked with aren't returned again later
1588+
/// let length = buffer.len();
15941589
/// stdin.consume(length);
15951590
/// ```
15961591
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)