Skip to content

Commit a98f429

Browse files
committed
Improve body trait/lifetime API
Now that rust-lang/rust#16453 has landed, the body API can be improved to not require hard casting to trait objects
1 parent fbf7c03 commit a98f429

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/http/body.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::io::{BufReader,IoResult,Reader};
22

33
pub enum Body<'a> {
44
FixedBody(BufReader<'a>, uint),
5-
ChunkedBody(&'a mut Reader + Send)
5+
ChunkedBody(&'a mut Reader+'a)
66
}
77

88
impl<'a> Body<'a> {
@@ -43,8 +43,7 @@ impl<'a> ToBody<'a> for &'a String {
4343
}
4444
}
4545

46-
// TODO: https://github.com/rust-lang/rust/issues/14901
47-
impl<'a> ToBody<'a> for &'a mut Reader + Send {
46+
impl<'a, R: 'a+Reader> ToBody<'a> for &'a mut R {
4847
fn to_body(self) -> Body<'a> {
4948
ChunkedBody(self)
5049
}

src/test/post.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn test_post_binary_with_reader() {
7171

7272
let mut body = MemReader::new(Vec::from_slice(b"Foo Bar Baz"));
7373
let res = http::handle()
74-
.post(server::url("/"), &mut body as &mut Reader)
74+
.post(server::url("/"), &mut body)
7575
.exec().unwrap();
7676

7777
srv.assert();
@@ -97,7 +97,7 @@ pub fn test_post_binary_with_reader_and_content_length() {
9797

9898
let mut body = MemReader::new(Vec::from_slice(b"Foo Bar Baz"));
9999
let res = http::handle()
100-
.post(server::url("/"), &mut body as &mut Reader)
100+
.post(server::url("/"), &mut body)
101101
.content_length(11)
102102
.exec().unwrap();
103103

src/test/server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl OpSequence {
116116
to_debug_str(b.as_slice()), to_debug_str(act.as_slice())));
117117
}
118118
}
119-
&Wait(ms) => { timer::sleep(Duration::milliseconds(ms as i32)) }
119+
&Wait(ms) => { timer::sleep(Duration::milliseconds(ms as i64)) }
120120
&Shutdown => return Err("Shutdown must be sent on its own".to_string())
121121
}
122122
}

0 commit comments

Comments
 (0)