Uses and_then instead of more complicated matching

This commit is contained in:
Sam Gibson 2015-08-27 18:39:15 +12:00
parent 84ae53e011
commit 1811ffa178

View file

@ -124,20 +124,20 @@ pub trait HttpResponse: Read {
fn status_raw(&self) -> &RawStatus; fn status_raw(&self) -> &RawStatus;
fn content_encoding(&self) -> Option<Encoding> { fn content_encoding(&self) -> Option<Encoding> {
match self.headers().get::<ContentEncoding>() { self.headers().get::<ContentEncoding>().and_then(|h| {
Some(&ContentEncoding(ref encodings)) => { match h {
if encodings.contains(&Encoding::Gzip) { &ContentEncoding(ref encodings) => {
Some(Encoding::Gzip) if encodings.contains(&Encoding::Gzip) {
} else if encodings.contains(&Encoding::Deflate) { Some(Encoding::Gzip)
Some(Encoding::Deflate) } else if encodings.contains(&Encoding::Deflate) {
} else { Some(Encoding::Deflate)
// TODO: Is this the correct behaviour? } else {
None // TODO: Is this the correct behaviour?
None
}
} }
} }
})
None => None
}
} }
} }