Skip to content

Commit c77cd3d

Browse files
committed
(fix) unwrap() => into_inner()
1 parent ba758ec commit c77cd3d

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/client/request.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ impl Request<Streaming> {
187187
///
188188
/// Consumes the Request.
189189
pub fn send(self) -> HttpResult<Response> {
190-
let raw = try!(self.body.end()).unwrap();
190+
let raw = try!(self.body.end()).into_inner();
191191
Response::new(raw)
192192
}
193193
}
@@ -219,8 +219,8 @@ mod tests {
219219
Get, Url::parse("http://example.dom").unwrap()
220220
).unwrap();
221221
let req = req.start().unwrap();
222-
let stream = *req.body.end().unwrap().unwrap().downcast::<MockStream>().unwrap();
223-
let bytes = stream.write.unwrap();
222+
let stream = *req.body.end().unwrap().into_inner().downcast::<MockStream>().unwrap();
223+
let bytes = stream.write.into_inner();
224224
let s = from_utf8(bytes[]).unwrap();
225225
assert!(!s.contains("Content-Length:"));
226226
assert!(!s.contains("Transfer-Encoding:"));
@@ -232,8 +232,8 @@ mod tests {
232232
Head, Url::parse("http://example.dom").unwrap()
233233
).unwrap();
234234
let req = req.start().unwrap();
235-
let stream = *req.body.end().unwrap().unwrap().downcast::<MockStream>().unwrap();
236-
let bytes = stream.write.unwrap();
235+
let stream = *req.body.end().unwrap().into_inner().downcast::<MockStream>().unwrap();
236+
let bytes = stream.write.into_inner();
237237
let s = from_utf8(bytes[]).unwrap();
238238
assert!(!s.contains("Content-Length:"));
239239
assert!(!s.contains("Transfer-Encoding:"));

src/client/response.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ impl Response {
8080
&self.status_raw
8181
}
8282

83-
/// Unwraps the Request to return the NetworkStream underneath.
84-
pub fn unwrap(self) -> Box<NetworkStream + Send> {
85-
self.body.unwrap().unwrap()
83+
/// Consumes the Request to return the NetworkStream underneath.
84+
pub fn into_inner(self) -> Box<NetworkStream + Send> {
85+
self.body.unwrap().into_inner()
8686
}
8787
}
8888

@@ -120,7 +120,7 @@ mod tests {
120120
status_raw: RawStatus(200, Slice("OK"))
121121
};
122122

123-
let b = res.unwrap().downcast::<MockStream>().unwrap();
123+
let b = res.into_inner().downcast::<MockStream>().unwrap();
124124
assert_eq!(b, box MockStream::new());
125125

126126
}

src/http.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ mod tests {
748748
let mut w = super::HttpWriter::ChunkedWriter(MemWriter::new());
749749
w.write(b"foo bar").unwrap();
750750
w.write(b"baz quux herp").unwrap();
751-
let buf = w.end().unwrap().unwrap();
751+
let buf = w.end().unwrap().into_inner();
752752
let s = from_utf8(buf.as_slice()).unwrap();
753753
assert_eq!(s, "7\r\nfoo bar\r\nD\r\nbaz quux herp\r\n0\r\n\r\n");
754754
}
@@ -760,7 +760,7 @@ mod tests {
760760
w.write(b"foo bar").unwrap();
761761
assert_eq!(w.write(b"baz"), Err(io::standard_error(io::ShortWrite(1))));
762762

763-
let buf = w.end().unwrap().unwrap();
763+
let buf = w.end().unwrap().into_inner();
764764
let s = from_utf8(buf.as_slice()).unwrap();
765765
assert_eq!(s, "foo barb");
766766
}

0 commit comments

Comments
 (0)