about summary refs log tree commit diff
path: root/src/libstd/net
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2018-07-24 16:43:49 -0600
committerGitHub <noreply@github.com>2018-07-24 16:43:49 -0600
commitc7a178ea5f84620508efbee96fb1da287c1a779d (patch)
treeaecd1021fb355e9f2d638b04712a308b3954a298 /src/libstd/net
parent28f8cb585aa4953864f64fdc58da9d4a2a34d6c0 (diff)
parentcbe5f1c4207673b9059e832ef2f134b4f87b380d (diff)
downloadrust-c7a178ea5f84620508efbee96fb1da287c1a779d.tar.gz
rust-c7a178ea5f84620508efbee96fb1da287c1a779d.zip
Rollup merge of #52658 - Wallacoloo:topics/use-option-methods, r=cramertj
Prefer `Option::map`/etc over `match` wherever it improves clarity

This isn't intended to change behavior anywhere. A lot of times statements like `match x { None => None, Some(y) => [...] }` can be rewritten using `Option::map` or `Option::and_then` in a way that preserves or improves clarity, so that's what I've done here.

I think it's particularly valuable to keep things in `libcore` and `libstd` pretty/idiomatic since it's not uncommon to follow the `[src]` links when browsing the rust-lang.org docs for std/core. If there's any concern about pushing style-based changes though, I'll happily back out the non-std/core commits here.
Diffstat (limited to 'src/libstd/net')
-rw-r--r--src/libstd/net/parser.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs
index ae5037cc44e..008c5da171f 100644
--- a/src/libstd/net/parser.rs
+++ b/src/libstd/net/parser.rs
@@ -53,10 +53,7 @@ impl<'a> Parser<'a> {
         F: FnOnce(&mut Parser) -> Option<T>,
     {
         self.read_atomically(move |p| {
-            match cb(p) {
-                Some(x) => if p.is_eof() {Some(x)} else {None},
-                None => None,
-            }
+            cb(p).filter(|_| p.is_eof())
         })
     }