async-rs / async-rs/async-std

TcpListener echo example is confusing

Open
#468 2 comments 0 reactions 0 assignees View on GitHub
question/feedback
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.