From c77cd3d3da351afce0bee9f36cde78924c5ea190 Mon Sep 17 00:00:00 2001 From: Evgeny Rozaliev Date: Thu, 27 Nov 2014 16:00:24 +0300 Subject: [PATCH] (fix) unwrap() => into_inner() --- src/client/request.rs | 10 +++++----- src/client/response.rs | 8 ++++---- src/http.rs | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/client/request.rs b/src/client/request.rs index 7102c665..6f9c8579 100644 --- a/src/client/request.rs +++ b/src/client/request.rs @@ -187,7 +187,7 @@ impl Request { /// /// Consumes the Request. pub fn send(self) -> HttpResult { - let raw = try!(self.body.end()).unwrap(); + let raw = try!(self.body.end()).into_inner(); Response::new(raw) } } @@ -219,8 +219,8 @@ mod tests { Get, Url::parse("http://example.dom").unwrap() ).unwrap(); let req = req.start().unwrap(); - let stream = *req.body.end().unwrap().unwrap().downcast::().unwrap(); - let bytes = stream.write.unwrap(); + let stream = *req.body.end().unwrap().into_inner().downcast::().unwrap(); + let bytes = stream.write.into_inner(); let s = from_utf8(bytes[]).unwrap(); assert!(!s.contains("Content-Length:")); assert!(!s.contains("Transfer-Encoding:")); @@ -232,8 +232,8 @@ mod tests { Head, Url::parse("http://example.dom").unwrap() ).unwrap(); let req = req.start().unwrap(); - let stream = *req.body.end().unwrap().unwrap().downcast::().unwrap(); - let bytes = stream.write.unwrap(); + let stream = *req.body.end().unwrap().into_inner().downcast::().unwrap(); + let bytes = stream.write.into_inner(); let s = from_utf8(bytes[]).unwrap(); assert!(!s.contains("Content-Length:")); assert!(!s.contains("Transfer-Encoding:")); diff --git a/src/client/response.rs b/src/client/response.rs index 39196a41..830e49bf 100644 --- a/src/client/response.rs +++ b/src/client/response.rs @@ -80,9 +80,9 @@ impl Response { &self.status_raw } - /// Unwraps the Request to return the NetworkStream underneath. - pub fn unwrap(self) -> Box { - self.body.unwrap().unwrap() + /// Consumes the Request to return the NetworkStream underneath. + pub fn into_inner(self) -> Box { + self.body.unwrap().into_inner() } } @@ -120,7 +120,7 @@ mod tests { status_raw: RawStatus(200, Slice("OK")) }; - let b = res.unwrap().downcast::().unwrap(); + let b = res.into_inner().downcast::().unwrap(); assert_eq!(b, box MockStream::new()); } diff --git a/src/http.rs b/src/http.rs index 77ddb6f7..bfc22a5d 100644 --- a/src/http.rs +++ b/src/http.rs @@ -748,7 +748,7 @@ mod tests { let mut w = super::HttpWriter::ChunkedWriter(MemWriter::new()); w.write(b"foo bar").unwrap(); w.write(b"baz quux herp").unwrap(); - let buf = w.end().unwrap().unwrap(); + let buf = w.end().unwrap().into_inner(); let s = from_utf8(buf.as_slice()).unwrap(); assert_eq!(s, "7\r\nfoo bar\r\nD\r\nbaz quux herp\r\n0\r\n\r\n"); } @@ -760,7 +760,7 @@ mod tests { w.write(b"foo bar").unwrap(); assert_eq!(w.write(b"baz"), Err(io::standard_error(io::ShortWrite(1)))); - let buf = w.end().unwrap().unwrap(); + let buf = w.end().unwrap().into_inner(); let s = from_utf8(buf.as_slice()).unwrap(); assert_eq!(s, "foo barb"); }