Skip to content

Commit fc2dfd6

Browse files
cakebakersylvestre
authored andcommitted
sort: make return value of loop explicit
1 parent 5716c84 commit fc2dfd6

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/uu/sort/src/merge.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,23 +309,21 @@ impl FileMerger<'_> {
309309
}
310310

311311
fn write_all_to(mut self, settings: &GlobalSettings, out: &mut impl Write) -> UResult<()> {
312-
let mut write_result = Ok(());
313-
loop {
312+
let write_result = loop {
314313
match self
315314
.write_next(out, settings)
316315
.map_err_context(|| "write failed".into())
317316
{
318317
Ok(true) => (),
319-
Ok(false) => break,
318+
Ok(false) => break Ok(()),
320319
Err(error) => {
321320
// Don't return yet: we still have to shut the reader thread down in an
322321
// orderly fashion below. Returning here would drop our receivers while
323322
// the reader is still sending, and `chunks::read` unwraps that send.
324-
write_result = Err(error);
325-
break;
323+
break Err(error);
326324
}
327325
}
328-
}
326+
};
329327

330328
let Self {
331329
heap,

0 commit comments

Comments
 (0)