From 1811ffa17874461811d7b8f15038b087458011e3 Mon Sep 17 00:00:00 2001 From: Sam Gibson Date: Thu, 27 Aug 2015 18:39:15 +1200 Subject: [PATCH] Uses `and_then` instead of more complicated matching --- components/net/http_loader.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 464e7bc54b1..6bf324949ca 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -124,20 +124,20 @@ pub trait HttpResponse: Read { fn status_raw(&self) -> &RawStatus; fn content_encoding(&self) -> Option { - match self.headers().get::() { - Some(&ContentEncoding(ref encodings)) => { - if encodings.contains(&Encoding::Gzip) { - Some(Encoding::Gzip) - } else if encodings.contains(&Encoding::Deflate) { - Some(Encoding::Deflate) - } else { - // TODO: Is this the correct behaviour? - None + self.headers().get::().and_then(|h| { + match h { + &ContentEncoding(ref encodings) => { + if encodings.contains(&Encoding::Gzip) { + Some(Encoding::Gzip) + } else if encodings.contains(&Encoding::Deflate) { + Some(Encoding::Deflate) + } else { + // TODO: Is this the correct behaviour? + None + } } } - - None => None - } + }) } }