TcpListener echo example is confusing
- Dominant language
- Rust
- Stars
- 4.1k
- Forks
- 339
- PR merge metrics
- No merged PRs in 30d
Description
Echo server example in TcpListener seems confusing to a new-comer.
```rust
while let Some(stream) = incoming.next().await {
let stream = stream?; -- Immutable binding
let (reader, writer) = &mut (&stream, &stream); -- This take mutable reference of immutable references
io::copy(reader, writer).await?; -- but io requires mutable access.
}
```
It's not clear how `io::copy` can use reader and writer which are basically `&mut &TcpStream`
Contributor guide
Research direction
Start with the TcpListener echo server example shown in the issue and inspect how its stream and io::copy usage are documented. Verify why the mutable references compile, then clarify the example or its explanation so a newcomer can understand the reader and writer types and confirm the example remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100