diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-04-25 18:30:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-25 18:30:30 +0200 |
| commit | 9709785d127964fe53f6cdf91b62363675f08e06 (patch) | |
| tree | 5e37793104a49a51fee885b3e044eed5861d9a9f /src/libstd | |
| parent | 939c93208c306596d84f632acb0245542f3d46aa (diff) | |
| parent | 4282776b1c394ed470d33f95c62538a2d37b16d3 (diff) | |
Rollup merge of #71544 - cuviper:filter_map_next, r=Mark-Simulacrum
Replace filter_map().next() calls with find_map() These are semantically the same, but `find_map()` is more concise.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/buffered.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 8862226adbb..16ca539b3c1 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -1043,15 +1043,10 @@ impl<W: Write> Write for LineWriter<W> { } // Find the last newline, and failing that write the whole buffer - let last_newline = bufs - .iter() - .enumerate() - .rev() - .filter_map(|(i, buf)| { - let pos = memchr::memrchr(b'\n', buf)?; - Some((i, pos)) - }) - .next(); + let last_newline = bufs.iter().enumerate().rev().find_map(|(i, buf)| { + let pos = memchr::memrchr(b'\n', buf)?; + Some((i, pos)) + }); let (i, j) = match last_newline { Some(pair) => pair, None => return self.inner.write_vectored(bufs), |
