Skip to content

Commit e8fe83f

Browse files
committed
Remove unused loop
We only simulate a single connection in the test function `serve_tcp`. Remove the unused loop (includes an unconditional break after first iteration) and use `next` directly. Found by clippy. Refactor only, no logic changes.
1 parent d9876aa commit e8fe83f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/network/stream_reader.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,15 @@ mod test {
203203
// 2. Spawning thread that will be writing our messages to the TCP Stream at the server side
204204
// in async mode
205205
let handle = thread::spawn(move || {
206-
for ostream in listener.incoming() {
207-
let mut ostream = ostream.unwrap();
208-
209-
for piece in pieces {
210-
ostream.write_all(&piece[..]).unwrap();
211-
ostream.flush().unwrap();
212-
thread::sleep(Duration::from_secs(1));
213-
}
214-
215-
ostream.shutdown(Shutdown::Both).unwrap();
216-
break;
206+
// We only simulate a single connection.
207+
let mut ostream = listener.incoming().next().unwrap().unwrap();
208+
for piece in pieces {
209+
ostream.write_all(&piece[..]).unwrap();
210+
ostream.flush().unwrap();
211+
thread::sleep(Duration::from_secs(1));
217212
}
213+
214+
ostream.shutdown(Shutdown::Both).unwrap();
218215
});
219216

220217
// 3. Creating client side of the TCP socket connection

0 commit comments

Comments
 (0)