-
I have searched open and closed issues and pull requests for duplicates, using these search terms:
-
I have checked the latest main branch to see if this has already been fixed, in this file:
URL to the section(s) of the book with this problem:
https://doc.rust-lang.org/book/ch20-01-single-threaded.html
https://doc.rust-lang.org/book/ch20-02-multithreaded.html
Description of the problem:
In all the code listings in Chapter 20, a BufReader is used to read the HTTP request. The BufReader is initialized using a mutable borrow of TcpStream:
let buf_reader = BufReader::new(&mut stream);
However, it seems the mutable borrow isn't necessary here. The code works just fine when mut is removed. What's the consideration here?
Suggested fix:
Change the initialization to use immutable borrow.
let buf_reader = BufReader::new(&stream);
I have searched open and closed issues and pull requests for duplicates, using these search terms:
BufReaderI have checked the latest
mainbranch to see if this has already been fixed, in this file:URL to the section(s) of the book with this problem:
https://doc.rust-lang.org/book/ch20-01-single-threaded.html
https://doc.rust-lang.org/book/ch20-02-multithreaded.html
Description of the problem:
In all the code listings in Chapter 20, a
BufReaderis used to read the HTTP request. The BufReader is initialized using a mutable borrow of TcpStream:However, it seems the mutable borrow isn't necessary here. The code works just fine when
mutis removed. What's the consideration here?Suggested fix:
Change the initialization to use immutable borrow.