Rollup merge of #43366 - leshow:bufreader-docs, r=aturon
Fix docs: BufReader/File doesn't need to be mut Neither `BufReader` nor `File` need to be declared `mut` for most of these examples. The cookbook example using `BufReader` doesn't declare them as `mut` either (https://brson.github.io/rust-cookbook/basics.html#ex-std-read-lines).
This commit is contained in:
commit
f1537da0e8
@ -37,7 +37,7 @@
|
||||
/// use std::fs::File;
|
||||
///
|
||||
/// # fn foo() -> std::io::Result<()> {
|
||||
/// let mut f = File::open("log.txt")?;
|
||||
/// let f = File::open("log.txt")?;
|
||||
/// let mut reader = BufReader::new(f);
|
||||
///
|
||||
/// let mut line = String::new();
|
||||
@ -64,8 +64,8 @@ impl<R: Read> BufReader<R> {
|
||||
/// use std::fs::File;
|
||||
///
|
||||
/// # fn foo() -> std::io::Result<()> {
|
||||
/// let mut f = File::open("log.txt")?;
|
||||
/// let mut reader = BufReader::new(f);
|
||||
/// let f = File::open("log.txt")?;
|
||||
/// let reader = BufReader::new(f);
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
@ -85,8 +85,8 @@ pub fn new(inner: R) -> BufReader<R> {
|
||||
/// use std::fs::File;
|
||||
///
|
||||
/// # fn foo() -> std::io::Result<()> {
|
||||
/// let mut f = File::open("log.txt")?;
|
||||
/// let mut reader = BufReader::with_capacity(10, f);
|
||||
/// let f = File::open("log.txt")?;
|
||||
/// let reader = BufReader::with_capacity(10, f);
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
@ -116,8 +116,8 @@ pub fn with_capacity(cap: usize, inner: R) -> BufReader<R> {
|
||||
/// use std::fs::File;
|
||||
///
|
||||
/// # fn foo() -> std::io::Result<()> {
|
||||
/// let mut f1 = File::open("log.txt")?;
|
||||
/// let mut reader = BufReader::new(f1);
|
||||
/// let f1 = File::open("log.txt")?;
|
||||
/// let reader = BufReader::new(f1);
|
||||
///
|
||||
/// let f2 = reader.get_ref();
|
||||
/// # Ok(())
|
||||
@ -137,7 +137,7 @@ pub fn get_ref(&self) -> &R { &self.inner }
|
||||
/// use std::fs::File;
|
||||
///
|
||||
/// # fn foo() -> std::io::Result<()> {
|
||||
/// let mut f1 = File::open("log.txt")?;
|
||||
/// let f1 = File::open("log.txt")?;
|
||||
/// let mut reader = BufReader::new(f1);
|
||||
///
|
||||
/// let f2 = reader.get_mut();
|
||||
@ -158,8 +158,8 @@ pub fn get_mut(&mut self) -> &mut R { &mut self.inner }
|
||||
/// use std::fs::File;
|
||||
///
|
||||
/// # fn foo() -> std::io::Result<()> {
|
||||
/// let mut f1 = File::open("log.txt")?;
|
||||
/// let mut reader = BufReader::new(f1);
|
||||
/// let f1 = File::open("log.txt")?;
|
||||
/// let reader = BufReader::new(f1);
|
||||
///
|
||||
/// let f2 = reader.into_inner();
|
||||
/// # Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user